TemplateVideo.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. public class TemplateVideo : BaseTemPlate
  6. {
  7. private Navigator.VideoControl m_VideoCtr;
  8. private AVProVideoPlayer m_Video;
  9. protected override void OnEnable()
  10. {
  11. base.OnEnable();
  12. //if (GameManager.Instance.IsRuning && string.IsNullOrWhiteSpace(m_VideoCtr.VideoURL))
  13. //{
  14. // if (File.Exists(Data.localSavePath))
  15. // {
  16. // m_VideoCtr.VideoURL = Data.localSavePath;
  17. // }
  18. // else
  19. // {
  20. // m_VideoCtr.VideoURL = null;
  21. // }
  22. //}
  23. //m_VideoCtr.m_IsPlaying = false;
  24. //m_VideoCtr.PlayVideo();
  25. if (GameManager.Instance.IsRuning && string.IsNullOrWhiteSpace(m_Video.GetUrl()))
  26. {
  27. if (File.Exists(Data.localSavePath))
  28. {
  29. m_Video.SetUrl(Data.localSavePath);
  30. }
  31. else
  32. {
  33. m_Video.SetUrl(null);
  34. }
  35. }
  36. m_Video.transform.GetComponent<VideoPlayBtn>().m_IsPlaying = false;
  37. m_Video.transform.GetComponent<VideoPlayBtn>().PlayVideo();
  38. }
  39. protected override void OnAwake()
  40. {
  41. base.OnAwake();
  42. // m_VideoCtr = transform.Find("Screen/Video").GetComponent<Navigator.VideoControl>();
  43. m_Video = transform.Find("Screen/AVideo").GetComponent<AVProVideoPlayer>();
  44. HideCollider();
  45. }
  46. public override void SetData(MaterialObjValue value, int updateTime)
  47. {
  48. base.SetData(value, updateTime);
  49. if (!GameManager.Instance.IsRuning)
  50. {
  51. DownloadManager.Instance.AddDownloadData(Data);
  52. }
  53. else
  54. {
  55. if (File.Exists(Data.localSavePath))
  56. {
  57. // m_VideoCtr.VideoURL = Data.localSavePath;
  58. m_Video.SetUrl(Data.localSavePath);
  59. }
  60. else
  61. {
  62. // m_VideoCtr.VideoURL = null;
  63. m_Video.SetUrl(null);
  64. }
  65. }
  66. }
  67. public void SetData(string url)
  68. {
  69. Debug.Log(url);
  70. //if(m_VideoCtr ==null)
  71. // m_VideoCtr = transform.Find("Screen/Video").GetComponent<Navigator.VideoControl>();
  72. //m_VideoCtr.VideoURL = url;
  73. if (m_Video == null)
  74. m_Video = transform.Find("Screen/AVideo").GetComponent<AVProVideoPlayer>();
  75. m_Video.SetUrl(url);
  76. }
  77. public override void HideCollider()
  78. {
  79. base.HideCollider();
  80. }
  81. }