UNITYで動画データをダウンロードして再生したいのですが、ダウンロードの処理で行き詰っています。
下記のようにwwwクラスを用いてドロップボックからダウンロードを試みたところ
www.progressが一瞬で100になり、2回目はファイルが存在しているとなるのですが、実際はダウンロードできていません。
ドロップボックが悪いのかと思い、ファイルサーバに直接ファイルを配置したところ
エディタでのデバッグではきちんとファイルがダウンロードされたのですが、iPhoneの実機でトライするとやはりダウンロードできていません。
アドバイスいただけると幸いです。
c#
1public void GetDownload(){ 2 StartCoroutine(StartDownload()); 3} 4 5IEnumerator StartDownload () { 6 WWW www; 7 string path=""; 8 string filename = "test.mp4"; 9 10 #if UNITY_EDITOR 11 path = "file:///"+Application.persistentDataPath + "/"; 12 #elif UNITY_ANDROID 13 path = "file://"+Application.persistentDataPath + "/"; 14 #endif 15 16 //iOS.Device.SetNoBackupFlag(path); 17 string url = "https://www.dropbox.com/s/xxxxxx/xxx.mp4?dl=0"; 18 19 if (System.IO.File.Exists (Application.persistentDataPath +"/"+ filename)) { 20 21 }else if (!System.IO.File.Exists (Application.persistentDataPath+"/"+ filename)) { 22 23 //存在しない場合はダウンロード 24 www = new WWW (url); 25 while(!www.isDone){ 26 Debug.Log ("Downloading... "+ (Mathf.CeilToInt(www.progress*100)); 27 yield return null; 28 } 29 System.IO.File.WriteAllBytes(Application.persistentDataPath+"/"+ filename , www.bytes); 30 31 } 32 33 Debug.Log("完了"); 34 35} 36 37 38
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/09/27 11:04