123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Video;
- using System;
- using UnityEngine.UI;
- using TMPro;
- public class RemoteVideoControl : MonoBehaviour
- {
- public GameObject Icon;
- public GameObject Stop;
- bool? isStart = true;
-
- public AVProVideoPlayer avProVideoPlayer;
- public Slider slider;
-
- public Text currentTime;
-
- public Text textTotalTime;
-
- private bool IsStart;
-
- private int hour, mint;
- private float time;
-
- public void VideoStartSwitch()
- {
-
- isStart = avProVideoPlayer.IsPlaying();
- isStart = !isStart;
-
-
- if (isStart.Value)
- {
-
- avProVideoPlayer?.Play();
- }
- else
- {
-
- avProVideoPlayer?.Pause();
- }
- }
- private void Start()
- {
- IsStart = true;
- slider.onValueChanged.AddListener(delegate { ChangeVideo(slider.value); });
- StartCoroutine(VideoTimer());
- }
- public void ChangeVideo(float value)
- {
-
-
-
-
-
-
-
-
- }
- 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.1f);
- if (avProVideoPlayer.IsVideoReady()&& !AVideoSlide.isDown)
- {
- float maxTimer = avProVideoPlayer.GetMaxTimer();
- float nowTimer = avProVideoPlayer.GetNowTimer();
- textTotalTime.text = string.Format("{0}:{1}", (maxTimer / 60).ToString("00"), (maxTimer % 60).ToString("00"));
- currentTime.text = string.Format("{0}:{1}", (nowTimer / 60).ToString("00"), (nowTimer % 60).ToString("00"));
- slider.value = maxTimer / nowTimer;
-
-
-
-
-
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
|