Files
ft/Client/Assets/Scripts/EventBlocks/UI/EventBlockVideoPlayer.cs
2026-06-29 21:18:33 +08:00

45 lines
1.5 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 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<TextAsset>(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($"<color=orange>{nameof(EventBlockVideoPlayer)} => {message}</color>");
#endif
}
}
}