Commit d18e74a39029aac8eb5cef08af42f0f2f471f584
1 parent
5991b828
Exists in
IosBuild
Writing video IOS
Showing
2 changed files
with
55 additions
and
9 deletions
Show diff stats
Assets/Scripts/Export Video/ExportVideo.cs
... | ... | @@ -82,15 +82,16 @@ public class ExportVideo : MonoBehaviour { |
82 | 82 | { |
83 | 83 | PlayerLogger.Log("ExportVideo", "OnClickExport", "Starting Export..."); |
84 | 84 | |
85 | - /* Aqui é o começo do processo de Exportar vídeo. Antes do processo realmente começar, deve-se checar se o app tem permissões para escrever | |
86 | - * no aparelho. Deve-se então trocar essa parte do código por uma abordagem iOS. NÃO ESQUECER DO CALLBACK PERMITTED. Caso contrário não | |
87 | - * será direcionado para próxima etapa do processo.*/ | |
88 | - | |
89 | - | |
85 | + /* Aqui é o começo do processo de Exportar vídeo. Antes do processo realmente começar, deve-se checar se o app tem permissões para escrever | |
86 | + * no aparelho. Deve-se então trocar essa parte do código por uma abordagem iOS. NÃO ESQUECER DO CALLBACK PERMITTED. Caso contrário não | |
87 | + * será direcionado para próxima etapa do processo.*/ | |
88 | + | |
89 | + | |
90 | 90 | /* |
91 | 91 | NoodlePermissionGranter.PermissionRequestCallback = Permitted; |
92 | 92 | NoodlePermissionGranter.GrantPermission(NoodlePermissionGranter.NoodleAndroidPermission.WRITE_EXTERNAL_STORAGE); |
93 | 93 | */ |
94 | + Permitted(true); | |
94 | 95 | |
95 | 96 | |
96 | 97 | } | ... | ... |
Assets/Scripts/Export Video/MediaShareIOS.cs
... | ... | @@ -18,20 +18,25 @@ using UnityEngine; |
18 | 18 | using System.Collections; |
19 | 19 | using System; |
20 | 20 | using LAViD.Unity.Utils; |
21 | +using System.IO; | |
21 | 22 | |
22 | 23 | |
23 | 24 | |
24 | 25 | public class MediaShareIOS : MonoBehaviour |
25 | 26 | { |
26 | 27 | |
27 | - private string MediaType = "video/*"; | |
28 | - private static string destination = ""; | |
29 | - private string VlibrasFolder = "DCIM/VLibras"; | |
28 | + private string MediaType = "video/*"; | |
29 | + private static string path; | |
30 | + private string VlibrasFolder = "VLibras"; | |
30 | 31 | private string Filen = "VLibrasVideo_"; |
31 | - private static string FilePath = ""; | |
32 | + private static string FilePath = ""; | |
32 | 33 | |
33 | 34 | |
34 | 35 | /*Makes sure that Vlibras Folder gets created and write the video bytes in it.*/ |
36 | + public void Awake() | |
37 | + { | |
38 | + path = Path.Combine(Application.persistentDataPath, VlibrasFolder); | |
39 | + } | |
35 | 40 | |
36 | 41 | public IEnumerator WriteOnIOS(byte[] videoContent, int bytes,string CurrentTime, Action finishWriting, Action errorWriting) |
37 | 42 | { |
... | ... | @@ -42,6 +47,46 @@ public class MediaShareIOS : MonoBehaviour |
42 | 47 | * chamado em caso de sucesso na escrita do vídeo, o segundo em caso de algum erro.*/ |
43 | 48 | /*É necessário que o arquivo seja salvo numa pasta própria do Vlibras de maneira que o usuário iOS possa visualizar o vídeo na galeria*/ |
44 | 49 | |
50 | + | |
51 | + | |
52 | + | |
53 | + /* Checking if folder Vlibras exists*/ | |
54 | + | |
55 | + DirectoryInfo dir = new DirectoryInfo(path); | |
56 | + if (!dir.Exists) | |
57 | + { | |
58 | + dir.Create(); | |
59 | + } | |
60 | + | |
61 | + try | |
62 | + { | |
63 | + FileStream SourceStream = new FileStream(Path.Combine(path, FilePath), FileMode.OpenOrCreate); | |
64 | + | |
65 | + if (SourceStream.CanWrite) | |
66 | + { | |
67 | + SourceStream.Write(videoContent, 0, bytes); | |
68 | + SourceStream.Close(); | |
69 | + finishWriting(); | |
70 | + | |
71 | + yield break; | |
72 | + | |
73 | + } | |
74 | + else | |
75 | + { | |
76 | + // new AndroidToast().showToast("Erro ao salvar vídeo.", "LONG"); | |
77 | + errorWriting(); | |
78 | + } | |
79 | + | |
80 | + | |
81 | + } | |
82 | + catch (Exception e) | |
83 | + { | |
84 | + PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.Message); | |
85 | + PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.StackTrace); | |
86 | + // new AndroidToast().showToast("Você precisa dá permissão ao aplicativo", "LONG"); | |
87 | + | |
88 | + errorWriting(); | |
89 | + } | |
45 | 90 | |
46 | 91 | yield break; |
47 | 92 | ... | ... |