seturl.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using RenderHeads.Media.AVProVideo;
  4. using UnityEngine;
  5. public class seturl : MonoBehaviour
  6. {
  7. public List<MediaPlayer> mp;
  8. public List<GameObject> mpView;
  9. List<string> urls = new List<string>();
  10. int ct;
  11. int pl = 0;
  12. int hc = 1;
  13. // Start is called before the first frame update
  14. void Start()
  15. {
  16. ct = 0;
  17. StartCoroutine(playVieo());
  18. }
  19. IEnumerator playVieo()
  20. {
  21. while(true)
  22. {
  23. if(urls.Count>0)
  24. {
  25. if(!mpView[0].activeSelf&& !mpView[1].activeSelf)
  26. {
  27. string url = urls[ct];
  28. MediaPath mpath = new MediaPath(url, MediaPathType.AbsolutePathOrURL);
  29. mp[pl].OpenMedia(mpath, true);
  30. }
  31. int hcct = ct;
  32. hcct++;
  33. if (hcct >= urls.Count)
  34. {
  35. hcct = 0;
  36. }
  37. string url2 = urls[hcct];
  38. MediaPath mpath2 = new MediaPath(url2, MediaPathType.AbsolutePathOrURL);
  39. mp[hc].OpenMedia(mpath2, true);
  40. mpView[pl].SetActive(true);
  41. mpView[hc].SetActive(false);
  42. int lspl = pl;
  43. pl = hc;
  44. hc = lspl;
  45. yield return new WaitForSeconds(20);
  46. while(!mp[pl].Control.IsPlaying())
  47. {
  48. yield return null;
  49. }
  50. ct++;
  51. if (ct >= urls.Count)
  52. {
  53. ct = 0;
  54. }
  55. }
  56. else
  57. {
  58. yield return null;
  59. }
  60. }
  61. }
  62. public void url(List<string> urls)
  63. {
  64. this.urls = urls;
  65. }
  66. }