using System; using System.IO; using RenderHeads.Media.AVProVideo; using UnityEngine; public class AVProVideoPlayer : MonoBehaviour { private void Awake() { this.m_player = base.GetComponent(); NDebug.Assert(this.m_player != null, "MediaPlayer コンポーネントが付いてないといけません。"); this.m_player.m_VideoLocation = MediaPlayer.FileLocation.AbsolutePathOrURL; this.m_player.m_VideoPath = this.m_player.m_VideoPath.Replace("\\", "/"); if (this.m_player.m_VideoPath.Contains("movie_temp/")) { this.m_player.m_VideoPath = this.m_player.m_VideoPath.Replace("movie_temp/", string.Empty); } if (this.m_player.m_VideoPath.Contains("/")) { this.m_player.m_VideoPath = UTY.gameProjectPath + "\\GameData\\" + this.m_player.m_VideoPath; } else { string path = UTY.gameProjectPath + "\\GameData\\"; string[] directories = Directory.GetDirectories(path, "movie*", SearchOption.TopDirectoryOnly); bool flag = false; foreach (string path2 in directories) { foreach (string text in Directory.GetFiles(path2)) { string fileName = Path.GetFileName(text); if (this.m_player.m_VideoPath == fileName) { flag = true; this.m_player.m_VideoPath = text; break; } } if (flag) { break; } } if (!flag) { Debug.LogErrorFormat("{0}がGameDataフォルダから見つかりませんでした", new object[] { this.m_player.m_VideoPath }); return; } } string dshowFilter = GameMain.Instance.CMSystem.SConfig.DShowFilter; MediaPlayer.OptionsWindows platformOptionsWindows = this.m_player.PlatformOptionsWindows; if (!string.IsNullOrEmpty(dshowFilter)) { platformOptionsWindows.preferredFilters.Add(dshowFilter); Debug.Log("[VideoPlayer] preferredFilters.Add(" + dshowFilter + ")."); } else { Debug.Log("[VideoPlayer] SConfig.DShowFilter\u3000には値が設定されていませんでした。"); } platformOptionsWindows.useHardwareDecoding = true; Debug.Log("[VideoPlayer] useHardwareDecoding = true."); platformOptionsWindows.videoApi = Windows.VideoApi.MediaFoundation; Debug.Log("[VideoPlayer] videoApi = " + platformOptionsWindows.videoApi.ToString()); } private void Start() { bool flag = this.m_player.OpenVideoFromFile(MediaPlayer.FileLocation.AbsolutePathOrURL, this.m_player.m_VideoPath, false); if (!flag) { NDebug.MessageBox("エラー", "ビデオファイルを開けませんでした。\nファイルの存在=" + File.Exists(this.m_player.m_VideoPath).ToString() + "\n" + this.m_player.m_VideoPath); } if (flag && this.m_player.VideoOpened && this.m_bAutoStart) { this.Play(); } } public void Play() { if (this.m_player.VideoOpened) { this.m_player.Play(); } } public void Stop() { if (this.m_player.VideoOpened) { this.m_player.Stop(); } } public void Speed(float f_fSpeed) { if (this.m_player.VideoOpened) { this.m_player.m_PlaybackRate = f_fSpeed; } } private MediaPlayer m_player; public bool m_bAutoStart; }