2023-11-19 17:45:25 +00:00
|
|
|
|
using OpenCVForUnity.VideoModule;
|
|
|
|
|
using System;
|
2023-11-17 06:44:27 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2023-11-19 17:45:25 +00:00
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
using UnityEngine.Video;
|
2023-11-17 06:44:27 +00:00
|
|
|
|
|
2023-11-19 17:45:25 +00:00
|
|
|
|
public class MeditationVideoUI : UIPanelBase
|
2023-11-17 06:44:27 +00:00
|
|
|
|
{
|
2023-11-19 17:45:25 +00:00
|
|
|
|
public VideoPlayer _video;
|
|
|
|
|
private bool _isInit = false;
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
_video = GetComponent<VideoPlayer>();
|
|
|
|
|
}
|
|
|
|
|
public override void Init(object[] pageData)
|
|
|
|
|
{
|
|
|
|
|
base.Init(pageData);
|
|
|
|
|
string videoPath = pageData[0] as string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
var video = Resources.Load<VideoClip>(videoPath);
|
|
|
|
|
_video.isLooping = true;
|
|
|
|
|
_video.playOnAwake = false;
|
|
|
|
|
_video.Prepare();
|
|
|
|
|
_video.loopPointReached += VideoEnd;
|
|
|
|
|
_isInit = true;
|
|
|
|
|
}
|
|
|
|
|
public override void OnEnter()
|
|
|
|
|
{
|
|
|
|
|
base.OnEnter();
|
|
|
|
|
_video.Play();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void VideoEnd(VideoPlayer source)
|
|
|
|
|
{
|
|
|
|
|
_video.Stop();
|
|
|
|
|
UIManager.Instance.CloseCurrent();
|
|
|
|
|
LoadingManager.Instance.Load("Boot");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnReturnBtnClicked()
|
2023-11-17 06:44:27 +00:00
|
|
|
|
{
|
2023-11-19 17:45:25 +00:00
|
|
|
|
VideoEnd(_video);
|
2023-11-17 06:44:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-19 17:45:25 +00:00
|
|
|
|
public override void OnExit()
|
2023-11-17 06:44:27 +00:00
|
|
|
|
{
|
2023-11-19 17:45:25 +00:00
|
|
|
|
base.OnExit();
|
|
|
|
|
_video.loopPointReached -= VideoEnd;
|
|
|
|
|
_isInit = false;
|
2023-11-17 06:44:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|