1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using System.IO;
- using RenderHeads.Media.AVProVideo;
- using UnityEngine;
- public class AVProVideoPlayer : MonoBehaviour
- {
- private void Awake()
- {
- this.m_player = base.GetComponent<MediaPlayer>();
- NDebug.Assert(this.m_player != null, "MediaPlayer コンポーネントが付いてないといけません。");
- this.m_player.m_VideoLocation = MediaPlayer.FileLocation.AbsolutePathOrURL;
- this.m_player.m_VideoPath = Path.GetFullPath(".\\") + "GameData\\" + this.m_player.m_VideoPath;
- 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);
- NDebug.Assert(flag, "ビデオファイルを開けませんでした。\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;
- }
|