Commit 97b90d3224b1214ea037f7a236e46bd7b536f003
1 parent
627a5379
Exists in
master
and in
2 other branches
Finish assync request
Showing
5 changed files
with
162 additions
and
129 deletions
Show diff stats
Assets/Scenes/Main.unity
... | ... | @@ -3592,53 +3592,53 @@ Animation: |
3592 | 3592 | m_GameObject: {fileID: 535548070} |
3593 | 3593 | m_Enabled: 1 |
3594 | 3594 | serializedVersion: 3 |
3595 | - m_Animation: {fileID: 7400000, guid: 365e5f41595503c48915848d883fabfe, type: 2} | |
3595 | + m_Animation: {fileID: 7400000, guid: 56fd236d710575546b549738e3dc9933, type: 2} | |
3596 | 3596 | m_Animations: |
3597 | - - {fileID: 7400000, guid: f1f36f20657e5244e9c1e21117d9a452, type: 2} | |
3598 | - - {fileID: 7400000, guid: 55bec2c04d14e74488ef127ee380a080, type: 2} | |
3599 | - - {fileID: 7400000, guid: b368bfe0efa37c04bb9c661058ccedb9, type: 2} | |
3600 | - - {fileID: 7400000, guid: 365e5f41595503c48915848d883fabfe, type: 2} | |
3601 | - - {fileID: 7400000, guid: fa9ef8a15fe08a143bc89dc00289fc17, type: 2} | |
3602 | - - {fileID: 7400000, guid: 939bebf16bb2dba44894c5745c5dc1f8, type: 2} | |
3603 | - - {fileID: 7400000, guid: aecdf652be04b444f84644ba7c403960, type: 2} | |
3604 | - - {fileID: 7400000, guid: 53ed20623f5573345a4fb057db454b05, type: 2} | |
3605 | - - {fileID: 7400000, guid: b0bafda258c57414ebfbc4cf89719795, type: 2} | |
3606 | - - {fileID: 7400000, guid: 67caa6e2d05387848a9448b57fffcb0f, type: 2} | |
3607 | - - {fileID: 7400000, guid: a79227e28dd60fa4c9812a51ab9d455e, type: 2} | |
3608 | - - {fileID: 7400000, guid: 8b1d930398178064795f5d23af67dce4, type: 2} | |
3609 | - - {fileID: 7400000, guid: af8192a32a30ab746be40ff1dcb8bc0a, type: 2} | |
3610 | - - {fileID: 7400000, guid: e282c734045b47241988e2b9fdf0dc7e, type: 2} | |
3611 | - - {fileID: 7400000, guid: 698d03f46785361449a10cc0003862eb, type: 2} | |
3612 | - - {fileID: 7400000, guid: e193836512c744c4299651990fc3ca10, type: 2} | |
3613 | - - {fileID: 7400000, guid: c4d452a56e2f4ee4a83e5679f969a354, type: 2} | |
3614 | - - {fileID: 7400000, guid: 220a675640cc72d4f9c8d364c9a377b4, type: 2} | |
3615 | - - {fileID: 7400000, guid: 9a1e34a6954967f4fb3982394bf61eef, type: 2} | |
3616 | - - {fileID: 7400000, guid: 039911b68664f7b40b97e2665893a1e5, type: 2} | |
3617 | - - {fileID: 7400000, guid: b4a4a507b5b85404f9ca30cf2855b359, type: 2} | |
3618 | - - {fileID: 7400000, guid: 3b67cb87e08f4e34badc00f7b49d2591, type: 2} | |
3619 | - - {fileID: 7400000, guid: dc854de773a9e3f488c7a1b42d6a460b, type: 2} | |
3620 | - - {fileID: 7400000, guid: 21b376087ddd4ec46a1da0c3ba1181d9, type: 2} | |
3621 | - - {fileID: 7400000, guid: db84b318b67dbc54fa1fab6d31dfeb6e, type: 2} | |
3622 | - - {fileID: 7400000, guid: 47e5da18eda740844ba111cfab49d0eb, type: 2} | |
3623 | - - {fileID: 7400000, guid: ba9dc32834cf193429f27449b1d9d701, type: 2} | |
3624 | - - {fileID: 7400000, guid: 22f7b3c892f0e5e41b120798d7953026, type: 2} | |
3625 | - - {fileID: 7400000, guid: 9396f2d833a082446b36b0cda61ba87c, type: 2} | |
3626 | - - {fileID: 7400000, guid: 289449396bffd4045b8657269df378f2, type: 2} | |
3627 | - - {fileID: 7400000, guid: 99bb7e6adbe6d5f4984c51d5d5e92045, type: 2} | |
3628 | - - {fileID: 7400000, guid: b6faf58a03a0dc24cb9777c70fda828b, type: 2} | |
3629 | - - {fileID: 7400000, guid: b2b18bfa970783a4ab32945b1c4bc54b, type: 2} | |
3630 | - - {fileID: 7400000, guid: a8b0488b23a43b3499d2b1d8b81f0707, type: 2} | |
3631 | - - {fileID: 7400000, guid: ccdf6bab5e56c0447abfc0a8f745b62c, type: 2} | |
3632 | - - {fileID: 7400000, guid: 8d2c7cdb67fea144e9660db7edd82239, type: 2} | |
3633 | - - {fileID: 7400000, guid: 6191f3fb2e8027b48ac60aa48c11065d, type: 2} | |
3634 | - - {fileID: 7400000, guid: dbf77a3c567182846bad50598584109d, type: 2} | |
3635 | - - {fileID: 7400000, guid: d2f41e4d1ce31a4458ccdab2cd91faae, type: 2} | |
3636 | - - {fileID: 7400000, guid: fc72e7fd88de0b94fb9b050fc1368547, type: 2} | |
3637 | - - {fileID: 7400000, guid: 5b7bf0ae891107f4aaa366ba42eac9ee, type: 2} | |
3638 | - - {fileID: 7400000, guid: d9c72b1fb167df045ae7ac711d1dee6c, type: 2} | |
3639 | - - {fileID: 7400000, guid: d927185f3fb021844834f7086d346e3a, type: 2} | |
3640 | - - {fileID: 7400000, guid: e62d77cfc7d0d104b84d8beb5ef72c33, type: 2} | |
3641 | - - {fileID: 7400000, guid: 1dd400df2179f94469eb2480a313a8cf, type: 2} | |
3597 | + - {fileID: 7400000, guid: 00ba6a68a60cf8348913c1e1d08225e3, type: 2} | |
3598 | + - {fileID: 7400000, guid: 024064fef8ad0984aa83a059ef0e97c8, type: 2} | |
3599 | + - {fileID: 7400000, guid: 0373e89bc94f97f42aefada1a5e994ac, type: 2} | |
3600 | + - {fileID: 7400000, guid: 0dbce6a38bccda54b8d8443be19c2905, type: 2} | |
3601 | + - {fileID: 7400000, guid: 27f596f7fb38c374986ba04b5bf611e8, type: 2} | |
3602 | + - {fileID: 7400000, guid: 2e44a90255a34fc4daaf3501a03ba3f3, type: 2} | |
3603 | + - {fileID: 7400000, guid: 2eb5f0288bd3a974ea446273239d009a, type: 2} | |
3604 | + - {fileID: 7400000, guid: 338176eab422f4343ae0ae772d51dfa6, type: 2} | |
3605 | + - {fileID: 7400000, guid: 360cc2b0364920c4ebc83c179b438ec1, type: 2} | |
3606 | + - {fileID: 7400000, guid: 36d0b9cf63020da4286cf20b16b495c5, type: 2} | |
3607 | + - {fileID: 7400000, guid: 37682432023174c4e9a65c33c5bcf6ad, type: 2} | |
3608 | + - {fileID: 7400000, guid: 37acbbb29e9f37645bc036795319ac94, type: 2} | |
3609 | + - {fileID: 7400000, guid: 37c181c0836f84d4a8e25e67948031dd, type: 2} | |
3610 | + - {fileID: 7400000, guid: 3d4889193e5c46d4a8a9ea1282279390, type: 2} | |
3611 | + - {fileID: 7400000, guid: 3dca07e4550670b4e842986e06aa5a41, type: 2} | |
3612 | + - {fileID: 7400000, guid: 3fd16a68343cc144cb70cb3db4b0aa9b, type: 2} | |
3613 | + - {fileID: 7400000, guid: 40d0a790b3070ce4d81fc3da05bb1963, type: 2} | |
3614 | + - {fileID: 7400000, guid: 4876b0814a4a3fd4386a47aead3d7207, type: 2} | |
3615 | + - {fileID: 7400000, guid: 48f6c6bc2bc27744e9f12e87e4b504eb, type: 2} | |
3616 | + - {fileID: 7400000, guid: 5600eee8fa75c8d4c92845cd1176bceb, type: 2} | |
3617 | + - {fileID: 7400000, guid: 56fd236d710575546b549738e3dc9933, type: 2} | |
3618 | + - {fileID: 7400000, guid: 5e103a53e53391843a93077f19061252, type: 2} | |
3619 | + - {fileID: 7400000, guid: 640c9d6234220764b893b1f4610cdd7e, type: 2} | |
3620 | + - {fileID: 7400000, guid: 67ff80d2ea811764582b3c4cfb2add22, type: 2} | |
3621 | + - {fileID: 7400000, guid: 6feff12708ff8c74282adac908065059, type: 2} | |
3622 | + - {fileID: 7400000, guid: 7391bb14ca59ae34582bb754db53a460, type: 2} | |
3623 | + - {fileID: 7400000, guid: 7952ed760df457746864064d057a1d9f, type: 2} | |
3624 | + - {fileID: 7400000, guid: 85921d4ab9939a74b8d2a58fc4163730, type: 2} | |
3625 | + - {fileID: 7400000, guid: 8d22d5e519d6b8e498f48b51631ce8f7, type: 2} | |
3626 | + - {fileID: 7400000, guid: 9d3f854d217779e47b726e84a47da4fe, type: 2} | |
3627 | + - {fileID: 7400000, guid: a1df8cb05298af045b2be5384f26437c, type: 2} | |
3628 | + - {fileID: 7400000, guid: ab8c477aa3617b348ac1537726e6842f, type: 2} | |
3629 | + - {fileID: 7400000, guid: b51aee90ed0d25840b3c3d07b0138c89, type: 2} | |
3630 | + - {fileID: 7400000, guid: beca8deb081aa4b4997e3d50fa3c04cc, type: 2} | |
3631 | + - {fileID: 7400000, guid: bee4bcce8696adb44b4af556524884d8, type: 2} | |
3632 | + - {fileID: 7400000, guid: bf04328d95b211f4b96bc4d5e4f5523c, type: 2} | |
3633 | + - {fileID: 7400000, guid: c1e3354da9dc9b74cacf65993ca5639e, type: 2} | |
3634 | + - {fileID: 7400000, guid: c888b74092e95d647bde3a70261c79a7, type: 2} | |
3635 | + - {fileID: 7400000, guid: d071f97fc9e45a745ad417f099115813, type: 2} | |
3636 | + - {fileID: 7400000, guid: d369df1e9db31e74e8bec69b7e1eeaef, type: 2} | |
3637 | + - {fileID: 7400000, guid: d4a1fa94131f32c418ffdadf548db9f2, type: 2} | |
3638 | + - {fileID: 7400000, guid: e1bee7fd96ded354aa9bd72e4008a4c5, type: 2} | |
3639 | + - {fileID: 7400000, guid: e3f85472d697c2b48a0f45c19e777c61, type: 2} | |
3640 | + - {fileID: 7400000, guid: ed5c2ec7af4ecdf46bc8ad611a9bbe9e, type: 2} | |
3641 | + - {fileID: 7400000, guid: f631fe8169818ba4aaf06daed9e39a7e, type: 2} | |
3642 | 3642 | m_WrapMode: 0 |
3643 | 3643 | m_PlayAutomatically: 1 |
3644 | 3644 | m_AnimatePhysics: 0 | ... | ... |
Assets/Scripts/Export Video/AndroidToast.cs
... | ... | @@ -25,7 +25,7 @@ public class AndroidToast |
25 | 25 | AndroidJavaObject context; |
26 | 26 | |
27 | 27 | public void showToast(string toastString,string lenght){ |
28 | -#if UNITY_ANDROID | |
28 | + | |
29 | 29 | if (Application.platform == RuntimePlatform.Android) |
30 | 30 | { |
31 | 31 | UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); |
... | ... | @@ -38,6 +38,6 @@ public class AndroidToast |
38 | 38 | toast.Call("show"); |
39 | 39 | } |
40 | 40 | } |
41 | -#endif | |
41 | + | |
42 | 42 | |
43 | 43 | } | ... | ... |
Assets/Scripts/Export Video/ExportVideo.cs
... | ... | @@ -32,7 +32,8 @@ public class ExportVideo : MonoBehaviour { |
32 | 32 | public ScreenManager screenManager; |
33 | 33 | public MediaShareAndroid MediaShareAndroid; |
34 | 34 | |
35 | - private const string SERVER_URL = "http://150.165.205.57/video/"; | |
35 | + private const string SERVER_URL = "http://150.165.205.84:80/video"; | |
36 | + | |
36 | 37 | |
37 | 38 | |
38 | 39 | private static string gloss = "Gloss"; |
... | ... | @@ -49,6 +50,7 @@ public class ExportVideo : MonoBehaviour { |
49 | 50 | private int videoSize = 0; |
50 | 51 | private int bytes = 0; |
51 | 52 | private string videoId = ""; |
53 | + private string videoFile = ""; | |
52 | 54 | private byte[] videoContent = null; |
53 | 55 | |
54 | 56 | /*Coroutine flags */ |
... | ... | @@ -71,9 +73,10 @@ public class ExportVideo : MonoBehaviour { |
71 | 73 | private void onClickExport() |
72 | 74 | { |
73 | 75 | PlayerLogger.Log("ExportVideo", "OnClickExport", "Starting Export..."); |
74 | - | |
75 | - NoodlePermissionGranter.PermissionRequestCallback = Permitted; | |
76 | - NoodlePermissionGranter.GrantPermission(NoodlePermissionGranter.NoodleAndroidPermission.WRITE_EXTERNAL_STORAGE); | |
76 | + | |
77 | + NoodlePermissionGranter.PermissionRequestCallback = Permitted; | |
78 | + NoodlePermissionGranter.GrantPermission(NoodlePermissionGranter.NoodleAndroidPermission.WRITE_EXTERNAL_STORAGE); | |
79 | + | |
77 | 80 | |
78 | 81 | |
79 | 82 | } |
... | ... | @@ -84,9 +87,33 @@ public class ExportVideo : MonoBehaviour { |
84 | 87 | { |
85 | 88 | if (PermissionGranted) |
86 | 89 | { |
90 | + int fiveTimesCount; | |
91 | + | |
92 | + if (PlayerPrefs.HasKey("fiveTimesCount")) | |
93 | + { | |
94 | + fiveTimesCount = PlayerPrefs.GetInt("fiveTimesCount"); | |
95 | + if(fiveTimesCount < 5) | |
96 | + { | |
97 | + fiveTimesCount++; | |
98 | + PlayerPrefs.SetInt("fiveTimesCount", fiveTimesCount); | |
99 | + PlayerPrefs.Save(); | |
100 | + | |
101 | + } | |
102 | + else | |
103 | + { | |
104 | + fiveTimesCount = 0; | |
105 | + PlayerPrefs.SetString("exportDialog", "declined"); | |
106 | + PlayerPrefs.Save(); | |
107 | + } | |
108 | + | |
109 | + }else | |
110 | + { | |
111 | + PlayerPrefs.SetFloat("fiveTimesCount", 0); | |
112 | + PlayerPrefs.Save(); | |
113 | + } | |
87 | 114 | bool accepted = false; |
88 | 115 | |
89 | - string message = "A geração do vídeo pode levar algum tempo."; | |
116 | + string message = "A geração de vídeo pode levar algum tempo."; | |
90 | 117 | if (PlayerPrefs.HasKey("exportDialog")) |
91 | 118 | { |
92 | 119 | accepted = PlayerPrefs.GetString("exportDialog").Equals("accepted"); |
... | ... | @@ -110,6 +137,7 @@ public class ExportVideo : MonoBehaviour { |
110 | 137 | screenManager.showPermissionDialog("Para salvar e compartilhar as animações, permita que o Vlibras acesse mídia e arquivos de seu aparelho.", "Exportar Vìdeo"); |
111 | 138 | // new AndroidToast().showToast("Você precisa dá permissão ao aplicativo.", "LONG"); |
112 | 139 | } |
140 | + | |
113 | 141 | |
114 | 142 | } |
115 | 143 | |
... | ... | @@ -136,7 +164,7 @@ public class ExportVideo : MonoBehaviour { |
136 | 164 | * shows the progress bar while getting video info*/ |
137 | 165 | public void startExport() |
138 | 166 | { |
139 | - new AndroidToast().showToast("Gerando Video...", "SHORT"); | |
167 | + // new AndroidToast().showToast("Gerando Video...", "SHORT"); | |
140 | 168 | screenManager.changeExportStates(ExportLayers.ExportLayer.Export_Layer, false); |
141 | 169 | |
142 | 170 | screenManager.changeExportStates(ExportLayers.ExportLayer.Progress_Layer, true); |
... | ... | @@ -310,7 +338,7 @@ public class ExportVideo : MonoBehaviour { |
310 | 338 | |
311 | 339 | FileContent fileContent = new FileContent(); |
312 | 340 | fileContent = FileContent.CreateFromJSON(videoInfoRequest.text); |
313 | - videoId = fileContent.file; | |
341 | + videoId = fileContent.id; | |
314 | 342 | StartCoroutine("VideoStatus"); |
315 | 343 | |
316 | 344 | } |
... | ... | @@ -332,12 +360,10 @@ public class ExportVideo : MonoBehaviour { |
332 | 360 | |
333 | 361 | private IEnumerator VideoStatus() |
334 | 362 | { |
335 | - | |
336 | - WWWForm JsonRequest = new WWWForm(); | |
337 | - JsonRequest.AddField("id", videoId); | |
338 | 363 | while (true) |
339 | 364 | { |
340 | - WWW videoStatusRequest = new WWW(SERVER_URL, JsonRequest); | |
365 | + WWW videoStatusRequest = new WWW(SERVER_URL + "/status/" + videoId); | |
366 | + Debug.Log(SERVER_URL + "/" + WWW.EscapeURL("status") + "/" + WWW.EscapeURL(videoId)); | |
341 | 367 | |
342 | 368 | |
343 | 369 | yield return WaitForResponse(videoStatusRequest); |
... | ... | @@ -395,9 +421,11 @@ public class ExportVideo : MonoBehaviour { |
395 | 421 | |
396 | 422 | |
397 | 423 | FileContent fileContent = new FileContent(); |
398 | - fileContent = FileContent.CreateFromJSON(videoStatusRequest.text); | |
399 | - if(fileContent.status == "done") | |
424 | + fileContent = FileContent.CreateFromJSON(videoStatusRequest.text); | |
425 | + if(fileContent.status.Equals("success")) | |
400 | 426 | { |
427 | + | |
428 | + videoFile = fileContent.file; | |
401 | 429 | videoSize = int.Parse(fileContent.size); |
402 | 430 | OnFinishGetVideoInfo(); |
403 | 431 | break; |
... | ... | @@ -415,10 +443,11 @@ public class ExportVideo : MonoBehaviour { |
415 | 443 | videoRequestRunning = false; |
416 | 444 | } |
417 | 445 | |
418 | - yield break; | |
446 | + | |
419 | 447 | |
420 | 448 | |
421 | 449 | }// while |
450 | + yield break; | |
422 | 451 | } |
423 | 452 | |
424 | 453 | |
... | ... | @@ -428,11 +457,11 @@ public class ExportVideo : MonoBehaviour { |
428 | 457 | private IEnumerator videoDownload() |
429 | 458 | { |
430 | 459 | videoDownloadRunning = true; |
431 | - WWW DownloadVideo = new WWW(SERVER_URL + videoId); | |
460 | + WWW DownloadVideo = new WWW(SERVER_URL + "/" + videoFile); | |
432 | 461 | |
433 | 462 | while (!DownloadVideo.isDone) |
434 | 463 | { |
435 | - screenManager.updateProgressDownloadSprite(DownloadVideo.progress); | |
464 | + screenManager.updateProgressDownloadSprite(DownloadVideo.psrogress); | |
436 | 465 | |
437 | 466 | yield return null; |
438 | 467 | } |
... | ... | @@ -504,7 +533,7 @@ public class ExportVideo : MonoBehaviour { |
504 | 533 | } |
505 | 534 | |
506 | 535 | /* Error states to show a Toast to user*/ |
507 | - private static void GetConnectionStatusError(ExportLayers.ConnectionStatusError error) | |
536 | + private void GetConnectionStatusError(ExportLayers.ConnectionStatusError error) | |
508 | 537 | { |
509 | 538 | switch (error) |
510 | 539 | { | ... | ... |
Assets/Scripts/Export Video/FileContent.cs
Assets/Scripts/Export Video/MediaShareAndroid.cs
... | ... | @@ -49,28 +49,29 @@ public class MediaShareAndroid : MonoBehaviour |
49 | 49 | |
50 | 50 | public IEnumerator WriteOnAndroid(byte[] videoContent, int bytes,string CurrentTime, Action finishWriting, Action errorWriting) |
51 | 51 | { |
52 | -#if UNITY_ANDROID | |
52 | + if (Application.platform == RuntimePlatform.Android) | |
53 | + { | |
53 | 54 | |
54 | - FilePath = Filen + CurrentTime + ".mp4"; | |
55 | - destination = Path.Combine(AndroidPath, Vlibras); | |
56 | - | |
55 | + FilePath = Filen + CurrentTime + ".mp4"; | |
56 | + destination = Path.Combine(AndroidPath, Vlibras); | |
57 | 57 | |
58 | - /* Checking if folder Vlibras exists*/ | |
59 | 58 | |
60 | - DirectoryInfo dir = new DirectoryInfo(destination); | |
61 | - if (!dir.Exists) | |
62 | - { | |
63 | - dir.Create(); | |
64 | - } | |
65 | - | |
66 | - try | |
67 | - { | |
59 | + /* Checking if folder Vlibras exists*/ | |
60 | + | |
61 | + DirectoryInfo dir = new DirectoryInfo(destination); | |
62 | + if (!dir.Exists) | |
63 | + { | |
64 | + dir.Create(); | |
65 | + } | |
66 | + | |
67 | + try | |
68 | + { | |
68 | 69 | FileStream SourceStream = new FileStream(Path.Combine(destination, FilePath), FileMode.OpenOrCreate); |
69 | 70 | if (SourceStream.CanWrite) |
70 | 71 | { |
71 | 72 | SourceStream.Write(videoContent, 0, bytes); |
72 | 73 | SourceStream.Close(); |
73 | - | |
74 | + | |
74 | 75 | Refresh(FilePath); |
75 | 76 | finishWriting(); |
76 | 77 | yield break; |
... | ... | @@ -78,23 +79,23 @@ public class MediaShareAndroid : MonoBehaviour |
78 | 79 | } |
79 | 80 | else |
80 | 81 | { |
81 | - new AndroidToast().showToast("Erro ao salvar vídeo.","LONG"); | |
82 | + new AndroidToast().showToast("Erro ao salvar vídeo.", "LONG"); | |
82 | 83 | errorWriting(); |
83 | 84 | } |
84 | 85 | |
85 | - | |
86 | - } | |
87 | - catch (Exception e) | |
88 | - { | |
89 | - PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid","Message: " + e.Message); | |
90 | - PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.StackTrace); | |
91 | - new AndroidToast().showToast("Você precisa dá permissão ao aplicativo","LONG"); | |
92 | - errorWriting(); | |
93 | - } | |
94 | 86 | |
95 | - | |
96 | - | |
97 | -#endif | |
87 | + } | |
88 | + catch (Exception e) | |
89 | + { | |
90 | + PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.Message); | |
91 | + PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.StackTrace); | |
92 | + new AndroidToast().showToast("Você precisa dá permissão ao aplicativo", "LONG"); | |
93 | + errorWriting(); | |
94 | + } | |
95 | + | |
96 | + | |
97 | + | |
98 | + } | |
98 | 99 | |
99 | 100 | |
100 | 101 | |
... | ... | @@ -105,19 +106,20 @@ public class MediaShareAndroid : MonoBehaviour |
105 | 106 | |
106 | 107 | private void Refresh(string FilePath) |
107 | 108 | { |
108 | -#if UNITY_ANDROID | |
109 | + if (Application.platform == RuntimePlatform.Android) | |
110 | + { | |
109 | 111 | |
110 | - AndroidJavaClass jcUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | |
112 | + AndroidJavaClass jcUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | |
111 | 113 | AndroidJavaObject joActivity = jcUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); |
112 | 114 | AndroidJavaObject joContext = joActivity.Call<AndroidJavaObject>("getApplicationContext"); |
113 | 115 | AndroidJavaClass jcMediaScannerConnection = new AndroidJavaClass("android.media.MediaScannerConnection"); |
114 | - //AndroidJavaClass jcEnvironment = new AndroidJavaClass("android.os.Environment"); | |
115 | - // AndroidJavaObject joExDir = jcEnvironment.CallStatic<AndroidJavaObject>("getExternalStorageDirectory"); | |
116 | - string path = destination; | |
117 | - jcMediaScannerConnection.CallStatic("scanFile", joContext, new string[] { path }, new string[] { "video/mp4" },null ); | |
116 | + //AndroidJavaClass jcEnvironment = new AndroidJavaClass("android.os.Environment"); | |
117 | + // AndroidJavaObject joExDir = jcEnvironment.CallStatic<AndroidJavaObject>("getExternalStorageDirectory"); | |
118 | + string path = destination; | |
119 | + jcMediaScannerConnection.CallStatic("scanFile", joContext, new string[] { path }, new string[] { "video/mp4" }, null); | |
118 | 120 | |
119 | 121 | |
120 | -#endif | |
122 | + } | |
121 | 123 | } |
122 | 124 | |
123 | 125 | |
... | ... | @@ -125,38 +127,39 @@ public class MediaShareAndroid : MonoBehaviour |
125 | 127 | |
126 | 128 | public IEnumerator ShareIntent(Action errorAction) { |
127 | 129 | |
128 | -#if UNITY_ANDROID | |
129 | - if (File.Exists(Path.Combine(destination, FilePath))) | |
130 | - { | |
131 | - | |
132 | - // block to open the file and share it ------------START | |
133 | - AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"); | |
134 | - AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent"); | |
135 | - intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND")); | |
136 | - | |
137 | - AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); | |
138 | - AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + Path.Combine(destination, FilePath)); | |
139 | - | |
140 | - intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject); | |
141 | - intentObject.Call<AndroidJavaObject>("setType", MediaType); | |
142 | - | |
143 | - //add data to be passed to the other activity i.e., the data to be sent | |
144 | - intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), "VLibras"); | |
145 | - intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), SubtitleMessage); | |
146 | - intentObject.Call<AndroidJavaObject>("setType", "video/*"); | |
147 | - AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | |
148 | - AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, "Compartilhar via"); | |
149 | - AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity"); | |
150 | - currentActivity.Call("startActivity", jChooser); | |
151 | - yield break; | |
152 | - }else | |
130 | + if (Application.platform == RuntimePlatform.Android) | |
153 | 131 | { |
154 | - errorAction(); | |
155 | - | |
156 | - yield break; | |
132 | + if (File.Exists(Path.Combine(destination, FilePath))) | |
133 | + { | |
134 | + | |
135 | + // block to open the file and share it ------------START | |
136 | + AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"); | |
137 | + AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent"); | |
138 | + intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND")); | |
139 | + | |
140 | + AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); | |
141 | + AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + Path.Combine(destination, FilePath)); | |
142 | + | |
143 | + intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject); | |
144 | + intentObject.Call<AndroidJavaObject>("setType", MediaType); | |
145 | + | |
146 | + //add data to be passed to the other activity i.e., the data to be sent | |
147 | + intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), "VLibras"); | |
148 | + intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), SubtitleMessage); | |
149 | + intentObject.Call<AndroidJavaObject>("setType", "video/*"); | |
150 | + AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | |
151 | + AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, "Compartilhar via"); | |
152 | + AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity"); | |
153 | + currentActivity.Call("startActivity", jChooser); | |
154 | + yield break; | |
155 | + } | |
156 | + else | |
157 | + { | |
158 | + errorAction(); | |
159 | + | |
160 | + yield break; | |
161 | + } | |
157 | 162 | } |
158 | - | |
159 | -#endif | |
160 | 163 | } |
161 | 164 | |
162 | 165 | } | ... | ... |