downloadmp4.cs 797 B

123456789101112131415161718192021222324252627282930313233
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Networking;
  5. public class downloadmp4 : MonoBehaviour
  6. {
  7. private void Awake()
  8. {
  9. StartCoroutine(LoadAB());
  10. }
  11. public string url;
  12. byte[] bytes;
  13. IEnumerator LoadAB()
  14. {
  15. string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, url);
  16. Debug.Log("loadMp4==" + filePath);
  17. //UnityWebRequest request = UnityWebRequest.Get(filePath);
  18. using (UnityWebRequest req = UnityWebRequest.Get(filePath))
  19. {
  20. yield return req.SendWebRequest();
  21. if (req.error == null)
  22. {
  23. bytes = req.downloadHandler.data;
  24. }
  25. else
  26. {
  27. }
  28. }
  29. }
  30. }