VideoPlayBtn.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. if (m_Video == null)
  19. m_Video = GetComponent<AVProVideoPlayer>();
  20. TemplateVideo.temQueue = new Queue<TemplateVideo>();
  21. TemplateVideo.isPlaying = false;
  22. GameManager.Instance.avplayer = null;
  23. Debug.Log("m_IsPlaying: " + m_IsPlaying);
  24. if (m_Video == null)
  25. return;
  26. Debug.Log(m_Video.GetUrl());
  27. if (!m_IsPlaying)
  28. {
  29. // FengMian.gameObject.SetActive(false);
  30. m_Video.Play();
  31. Icon.SetActive(false);
  32. }
  33. else
  34. {
  35. m_Video.Pause();
  36. Icon.SetActive(true);
  37. }
  38. m_IsPlaying = !m_IsPlaying;
  39. if (spid != null&& m_Video!=null&& !UserInfo.Instance.is20)
  40. MQTTClient.Instance.sendActiveVideo(spid, videoid, m_IsPlaying, -1);
  41. }
  42. public void PlayVideoAuto()
  43. {
  44. if (m_Video == null)
  45. m_Video = GetComponent<AVProVideoPlayer>();
  46. TemplateVideo.isPlayLock = true;
  47. Debug.Log("m_IsPlaying: " + m_IsPlaying);
  48. if (m_Video == null)
  49. return;
  50. Debug.Log(m_Video.GetUrl());
  51. if (!m_IsPlaying)
  52. {
  53. // FengMian.gameObject.SetActive(false);
  54. m_Video.Play();
  55. Icon.SetActive(false);
  56. }
  57. else
  58. {
  59. m_Video.Pause();
  60. Icon.SetActive(true);
  61. }
  62. m_IsPlaying = !m_IsPlaying;
  63. if (spid != null && m_Video != null && !UserInfo.Instance.is20)
  64. MQTTClient.Instance.sendActiveVideo(spid, videoid, m_IsPlaying, -1);
  65. }
  66. }