Browse Source

播放器状态

DGJ 1 year ago
parent
commit
1db61518ac
1 changed files with 66 additions and 8 deletions
  1. 66 8
      Assets/LangChaoRTC/Remote/ShowRoom/RemoteVideoControl.cs

+ 66 - 8
Assets/LangChaoRTC/Remote/ShowRoom/RemoteVideoControl.cs

@@ -30,8 +30,8 @@ public class RemoteVideoControl : MonoBehaviour
         // isStart = videoPlayer.isPlaying;
         isStart = avProVideoPlayer.IsPlaying();
         isStart = !isStart;
-        Icon.SetActive(!isStart.Value);
-        Stop.SetActive(isStart.Value);
+        //Icon.SetActive(!isStart.Value);
+        //Stop.SetActive(isStart.Value);
         if (isStart.Value)
         {
             //  videoPlayer?.Play();
@@ -66,11 +66,69 @@ public class RemoteVideoControl : MonoBehaviour
 
     float max;
 
+    private IEnumerator VideoState()
+    {
+        while(true)
+        {
+            yield return new WaitForSeconds(0.1f);
+
+            switch (avProVideoPlayer.GetVideoState())
+            {
+                case MediaPlayerCtrl.MEDIAPLAYER_STATE.NOT_READY:
+                    if (!Icon.activeSelf)
+                    {
+                        Icon.SetActive(true);
+                        Stop.SetActive(false);
+                    }
+                    break;
+                case MediaPlayerCtrl.MEDIAPLAYER_STATE.READY:
+                    break;
+                case MediaPlayerCtrl.MEDIAPLAYER_STATE.END:
+                    if (!Icon.activeSelf)
+                    {
+                        Icon.SetActive(true);
+                        Stop.SetActive(false);
+                    }
+                    break;
+                case MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING:
+                    if (Icon.activeSelf)
+                    {
+                        Icon.SetActive(false);
+                        Stop.SetActive(true);
+                    }
+                    break;
+                case MediaPlayerCtrl.MEDIAPLAYER_STATE.PAUSED:
+                    if (!Icon.activeSelf)
+                    {
+                        Icon.SetActive(true);
+                        Stop.SetActive(false);
+                    }
+                    break;
+                case MediaPlayerCtrl.MEDIAPLAYER_STATE.STOPPED:
+                    if (!Icon.activeSelf)
+                    {
+                        Icon.SetActive(true);
+                        Stop.SetActive(false);
+                    }
+                    break;
+                case MediaPlayerCtrl.MEDIAPLAYER_STATE.ERROR:
+                    if (!Icon.activeSelf)
+                    {
+                        Icon.SetActive(true);
+                        Stop.SetActive(false);
+                    }
+                    break;
+                default:
+                    break;
+            }
+        }
+    }
+
     private IEnumerator VideoTimer()
     {
         while (true)
         {
-            yield return new WaitForSeconds(0.05f);
+            yield return new WaitForSeconds(0.1f);
             if (avProVideoPlayer.IsVideoReady()&& !AVideoSlide.isDown)
             {
                 float maxTimer = avProVideoPlayer.GetMaxTimer();
@@ -79,11 +137,11 @@ public class RemoteVideoControl : MonoBehaviour
                 currentTime.text = string.Format("{0}:{1}", (nowTimer / 60).ToString("00"), (nowTimer % 60).ToString("00"));
                 slider.value = maxTimer / nowTimer;
 
-                if (textTotalTime.text == currentTime.text)
-                {
-                    Icon.SetActive(true);
-                    Stop.SetActive(false);
-                }
+                //if (textTotalTime.text == currentTime.text)
+                //{
+                //    Icon.SetActive(true);
+                //    Stop.SetActive(false);
+                //}
             }
 
         }