title: How can I play video from byte array, and not allow user get the raw file?
body: <p>My question is I store encrypted clip file in client. But video player only support video format file. </p>
  
  <p>So I convert byte array in to mp4 file. Anyone can provide a better solution to play byte array?</p>
  
  <p>My current method for trying to do this is:</p>
  
  <ol>
  <li>Write byte to a .mp4 file</li>
  <li>Load and play the .mp4 file by Video Player</li>
  <li>Delete the temp file after video is playing</li>
  </ol>
  
  <p>It seems works but I'm not sure whether it is safe.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>void Start()
  {
      byte[] data = EncryptManager.Instance.DecryptData(encryptedData);
      if (data != null){
              WriteByteArrayToFile("temp.mp4", data);
              videoPlayer.url = "temp.mp4";
              videoPlayer.source = VideoSource.Url;
       }
       StartCoroutine(ChekVideoLoading());
  }
  
  IEnumerator ChekVideoLoading()
  {
      while (!videoPlayer.isPlaying)
      {
          yield return null;
      }
      yield return new WaitForSeconds(1f);
      File.Delete("temp.mp4");
  }
  
  public void WriteByteArrayToFile(string fileName, byte[] data)
  {
      FileStream fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write);
      fileStream.Write(data, 0, data.Length);  
  }  
  </code></pre>