VideoPlayBtn.cs 813 B

1234567891011121314151617181920212223242526272829303132333435
  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. private void Start()
  10. {
  11. if (m_Video == null)
  12. m_Video = GetComponent<AVProVideoPlayer>();
  13. }
  14. public void PlayVideo()
  15. {
  16. Debug.Log("m_IsPlaying: " + m_IsPlaying);
  17. if (m_Video == null)
  18. return;
  19. Debug.Log(m_Video.GetUrl());
  20. if (!m_IsPlaying)
  21. {
  22. // FengMian.gameObject.SetActive(false);
  23. m_Video.Play();
  24. Icon.SetActive(false);
  25. }
  26. else
  27. {
  28. m_Video.Pause();
  29. Icon.SetActive(true);
  30. }
  31. m_IsPlaying = !m_IsPlaying;
  32. }
  33. }