VideoPlayBtn.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. Debug.Log("m_IsPlaying: " + m_IsPlaying);
  19. if (m_Video == null)
  20. return;
  21. Debug.Log(m_Video.GetUrl());
  22. if (!m_IsPlaying)
  23. {
  24. // FengMian.gameObject.SetActive(false);
  25. m_Video.Play();
  26. Icon.SetActive(false);
  27. }
  28. else
  29. {
  30. m_Video.Pause();
  31. Icon.SetActive(true);
  32. }
  33. m_IsPlaying = !m_IsPlaying;
  34. if (spid != null&& m_Video!=null&& !UserInfo.Instance.is20)
  35. MQTTClient.Instance.sendActiveVideo(spid, videoid, m_IsPlaying, -1);
  36. }
  37. }