38 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using RenderHeads.Media.AVProVideo;
using System;
public class AVProManager : MonoBehaviour
{
public MediaPlayer _mediaPlayer;
Action callBack;
void Start()
{
_mediaPlayer.Events.AddListener(OnMediaPlayerEvent);
}
//加载视频
public void PlayVideo(string name,Action callBack)
{
//通过插件中的方法加载参数为1.加载路径格式与面板上相对应2.加载的文件名 3.默认是否开始播放)
_mediaPlayer.OpenMedia(MediaPathType.RelativeToStreamingAssetsFolder, name, true);
this.callBack = callBack;
}
//关闭
public void Close()
{
_mediaPlayer.Control.Pause();
}
//监听
public void OnMediaPlayerEvent(MediaPlayer mp, MediaPlayerEvent.EventType et, ErrorCode errorCode)
{
switch (et)
{
case MediaPlayerEvent.EventType.Started:
break;
case MediaPlayerEvent.EventType.FinishedPlaying:
callBack?.Invoke();
break;
}
}
}