UnauthorizedAccessException: Access to the path 'path to file' is denied.
I'm looking for a way to download, save and play movies on Handheld devices. But everytime I build it to iOS and play it I get the UnauthorizedAccessException when it is trying the FileStream. At this point I'm totally stuck.......
Also couldn't find any other working solutions anywhere online.
Unity 5.6.3
using UnityEngine; using System.Collections; using System.IO;
public class movieStream : MonoBehaviour {
 private string videoName = "your-video-file.mp4";
 private string path;
 void Start()
 {
     Debug.Log("Initiated");
     StartCoroutine(DownloadAndPlayVideo());        
 }
 IEnumerator DownloadAndPlayVideo()
 {
     Debug.Log("IEnumerator Started");
     //Use this line when Android phone
     //path = Application.persistentDataPath + "/" + videoName;
     //Use this line when Iphone
     path = "file://" + Application.persistentDataPath + "/" + videoName;
     Debug.Log(path);
     WWW www = new WWW("https://img-9gag-fun.9cache.com/photo/aNzgP7A_460sv.mp4");
     yield return www;
     Debug.Log("Online movie found");
     if (www == null)
     {
         Debug.Log("www = Null");
     }
     else if (www.isDone)
     {
         Debug.Log("www is done");
     }
     else if (www.error != null)
     {
         Debug.Log("www has an error");
     }
     //Save the video to videoName location
     if (www != null && www.isDone && www.error == null)
     {
         Debug.Log("Save started");
         FileStream stream = new FileStream(videoName, FileMode.Create);
         stream.Write(www.bytes, 0, www.bytes.Length);
         stream.Close();
     }
     Debug.Log("starting Handheld");
     Handheld.PlayFullScreenMovie(path, Color.black, FullScreenMovieControlMode.Full, FullScreenMovieScalingMode.AspectFill);
     Debug.Log("stopping Handheld");
 }
}
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Handheld.PlayFullScreenMovie dont work, help 0 Answers
Cannot impory any video file. 0 Answers
Video won't show up on quad and Unity Hub can't create a new folder. 0 Answers
Access to the path is denied 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                