TemplateVideo.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. public class TemplateVideo : BaseTemPlate
  6. {
  7. private 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 override void HideCollider()
  68. {
  69. base.HideCollider();
  70. }
  71. }