//- using System; using System.Threading.Tasks; using EventCubeMelt; using UnityEngine; using UnityEngine.AddressableAssets; namespace EventBlocks.UI { public class EventBlockVideoPlayer : MonoBehaviour { //- 播放视频 public LeviathanVideoDecoder _videoDecoder; public async Task PlayVideo(string fileName) { ELog($"LoadVideoFile -> {fileName}"); var videoBytes = await Addressables.LoadAssetAsync(fileName).Task; // _videoDecoder.bytesFile = videoBytes; _videoDecoder.PlayVideo(videoBytes, LeviathanVideoDecoderBase.PlayAlphaType.ChromaKey, // None / RightSide / BottomSide / ChromaKey multithreadedDecode: true, // WebGL 下会被强制为 false(无 C# 线程) beginFrameIndex: 1, syncDecodeFirstFrame: true, // false:首帧异步,先隐藏 RawImage,首帧就绪后再显示(见 OnFirstFrameRendered) fastDecode: true // true:跳过环路滤波,解码更快、画质略降 ); } public void StopPlayVideo() { _videoDecoder.Stop(); } private static void ELog(string message) { #if UNITY_EDITOR if (!EventCubeMeltLogPolicy.EnableELog) return; Debug.Log($"{nameof(EventBlockVideoPlayer)} => {message}"); #endif } } }