VideoPlayBtn.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class VideoPlayBtn : MonoBehaviour
  5. {
  6. public GameObject Icon;
  7. public bool m_IsPlaying;
  8. public AVProVideoPlayer m_Video;
  9. public string spid = null;
  10. public string videoid = null;
  11. private void Start()
  12. {
  13. if (m_Video == null)
  14. m_Video = GetComponent<AVProVideoPlayer>();
  15. }
  16. public void PlayVideo()
  17. {
  18. TemplateVideo.temQueue = new Queue<TemplateVideo>();
  19. TemplateVideo.isPlaying = false;
  20. GameManager.Instance.avplayer = null;
  21. Debug.Log("m_IsPlaying: " + m_IsPlaying);
  22. if (m_Video == null)
  23. return;
  24. Debug.Log(m_Video.GetUrl());
  25. if (!m_IsPlaying)
  26. {
  27. // FengMian.gameObject.SetActive(false);
  28. m_Video.Play();
  29. Icon.SetActive(false);
  30. }
  31. else
  32. {
  33. m_Video.Pause();
  34. Icon.SetActive(true);
  35. }
  36. m_IsPlaying = !m_IsPlaying;
  37. if (spid != null&& m_Video!=null&& !UserInfo.Instance.is20)
  38. MQTTClient.Instance.sendActiveVideo(spid, videoid, m_IsPlaying, -1);
  39. }
  40. public void PlayVideoAuto()
  41. {
  42. TemplateVideo.isPlayLock = true;
  43. Debug.Log("m_IsPlaying: " + m_IsPlaying);
  44. if (m_Video == null)
  45. return;
  46. Debug.Log(m_Video.GetUrl());
  47. if (!m_IsPlaying)
  48. {
  49. // FengMian.gameObject.SetActive(false);
  50. m_Video.Play();
  51. Icon.SetActive(false);
  52. }
  53. else
  54. {
  55. m_Video.Pause();
  56. Icon.SetActive(true);
  57. }
  58. m_IsPlaying = !m_IsPlaying;
  59. if (spid != null && m_Video != null && !UserInfo.Instance.is20)
  60. MQTTClient.Instance.sendActiveVideo(spid, videoid, m_IsPlaying, -1);
  61. }
  62. }