50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using Gameplay.Performance;
|
|
using PhxhSDK;
|
|
using System.IO;
|
|
using YooAsset;
|
|
|
|
namespace Gameplay
|
|
{
|
|
public partial class CommonUtils
|
|
{
|
|
/// <summary>
|
|
/// 根据性能获取视频路径
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static void GetVideoPathByPerformance(ref string path)
|
|
{
|
|
if (!PerformanceManager.instance.data.useLowVideo)
|
|
return;
|
|
|
|
if (path.Contains("_Low"))
|
|
return;
|
|
|
|
int dotIndex = path.LastIndexOf('.');
|
|
path = path.Insert(dotIndex, "_Low");
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取播放视频的真实路径
|
|
/// </summary>
|
|
/// <param name="birthTime"></param>
|
|
/// <returns></returns>
|
|
public static async UniTask<string> GetRealVideoURL(string videoURL)
|
|
{
|
|
string realVideoURL;
|
|
RawFileHandle rawFileHandle = AssetManager.Instance.LoadRawFileAsync(videoURL);
|
|
await rawFileHandle;
|
|
string rawFilePath = rawFileHandle.GetRawFilePath();
|
|
if (rawFilePath.EndsWith(".mp4"))
|
|
realVideoURL = rawFilePath;
|
|
else
|
|
realVideoURL = $"{rawFilePath}.mp4";
|
|
|
|
if (!File.Exists(realVideoURL))
|
|
File.Copy(rawFilePath, realVideoURL);
|
|
|
|
return realVideoURL;
|
|
}
|
|
}
|
|
} |