using System.Collections; using System.Collections.Generic; using UnityEngine; using RenderHeads.Media.AVProVideo; public class AVPevent : MonoBehaviour { public MediaPlayer mediaplayer; void Start () { mediaplayer.Events.AddListener(OnMediaPlayerEvent); SetMovie("/game2/start/piantou.mp4"); } void SetMovie(string mp4Str)//gamex + "/start/piantou.mp4" { mediaplayer.OpenVideoFromFile(MediaPlayer.FileLocation.RelativeToStreamingAssetsFolder, Application.streamingAssetsPath + mp4Str, true); mediaplayer.m_Loop = false; mediaplayer.Play(); } /// <summary> /// AVPro事件管理 /// </summary> /// <param name="mp"></param> /// <param name="et"></param> /// <param name="errorCode"></param> void OnMediaPlayerEvent(MediaPlayer mp,MediaPlayerEvent.EventType et,ErrorCode errorCode) { switch (et) { case MediaPlayerEvent.EventType.Started: print("startedEvent开始事件触发"); OnMediaPlayerStarted(mp); break; case MediaPlayerEvent.EventType.FinishedPlaying: print("finishedEvent结束事件触发"); OnMediaPlayerFinished(mp); break; } } /// <summary> /// 开始事件触发 /// </summary> /// <param name="mp"></param> void OnMediaPlayerStarted(MediaPlayer mp) { print("开始事件触发的后续"); } /// <summary> /// 结束事件触发 /// </summary> /// <param name="mp"></param> void OnMediaPlayerFinished(MediaPlayer mp) { print("结束事件触发的后续"); if (mp.m_VideoPath.Contains("piantou")) SetMovie("/game2/time/movie.mp4"); else if (mp.m_VideoPath.Contains("movie")) SetMovie("/game2/start/piantou.mp4"); } // Update is called once per frame void Update () { } }