public new void Load(string path) { if (_player == null) { var assembly = Assembly.GetEntryAssembly(); string appDir = System.IO.Path.GetDirectoryName(assembly.Location); string dllPath = $@"{appDir}\lib\mpv-1.dll"; //单元测试 _player = new Mpv.NET.Player.MpvPlayer(Handle, dllPath) { Loop = true, Volume = 0 }; //防止视频黑边 _player.API.SetPropertyString("panscan", "1.0"); _player.AutoPlay = true; Load(_lastPath); } if (string.IsNullOrEmpty(path)) { return; } _lastPath = path; _player?.Pause(); _player?.Load(path); _player?.Resume(); }
public void LoadFile(string fileName) { if (_player != null) { cont.ebool = true; _player?.Stop(); _locker.PerformLockAction(() => { if (GetTemplateChild("PART_Seek") is Slider seek) { seek.Value = 0; } if (GetTemplateChild("PART_Volume") is Slider volume) { _player.Volume = Convert.ToInt32(volume.Value); } }); System.Threading.Thread.Sleep(100); _player.Load(fileName); System.Threading.Thread.Sleep(100); //GetChapters(); GetAudioAndSubtitles(); } }
public new void Load(string path) { if (_player == null) { var assembly = Assembly.GetEntryAssembly(); string appDir = System.IO.Path.GetDirectoryName(assembly.Location); string dllPath = $@"{appDir}\lib\mpv-1.dll"; if (IntPtr.Size == 4) { // 32-bit } else if (IntPtr.Size == 8) { // 64-bit dllPath = $@"{appDir}\lib\mpv-1-x64.dll"; } this.InvokeIfRequired(() => { //单元测试 _player = new Mpv.NET.Player.MpvPlayer(Handle, dllPath) { Loop = true, Volume = 0 }; //防止视频黑边 _player.API.SetPropertyString("panscan", "1.0"); _player.AutoPlay = true; _player.Volume = _volume; //Load(_lastPath); }); } if (string.IsNullOrEmpty(path)) { return; } try { System.Diagnostics.Debug.WriteLine("load video 0"); //_lastPath = path; // 设置解码模式为自动,如果条件允许,MPV会启动硬件解码 _player?.API.SetPropertyString("hwdec", "auto"); //_player.API.SetProperty("hwdec",Encoding.Default.GetBytes("auto")); _player?.Pause(); _player?.Load(path); _player?.Resume(); } catch (Exception ex) { } finally { System.Diagnostics.Debug.WriteLine("load video 1"); } }
public void LoadFile(string path) { if (string.IsNullOrEmpty(path)) { return; } _lastPath = path; _player?.Pause(); _player?.Load(path); _player?.Resume(); }
public void Play(string path) { if (_player == null) { var assembly = Assembly.GetEntryAssembly(); string appDir = System.IO.Path.GetDirectoryName(assembly.Location); string dllPath = $@"{appDir}\lib\mpv-1.dll"; if (IntPtr.Size == 4) { // 32-bit } else if (IntPtr.Size == 8) { // 64-bit dllPath = $@"{appDir}\lib\mpv-1-x64.dll"; } Util.InvokeIfRequired(() => { _player = new Mpv.NET.Player.MpvPlayer(Handle, dllPath) { Loop = true, Volume = 0 }; _player.AutoPlay = true; //Play(_lastPath); }); } if (string.IsNullOrEmpty(path)) { return; } //_lastPath = path; //防止视频黑边 _player.API.SetPropertyString("panscan", "1.0"); // 设置解码模式为自动,如果条件允许,MPV会启动硬件解码 _player?.API.SetPropertyString("hwdec", "auto"); //允许休眠 _player?.API.SetPropertyString("stop-screensaver", "no"); _player.Volume = _volume; //_player?.Pause(); _player?.Load(path); //_player?.Resume(); }
public new void Load(string path) { if (_player == null) { var assembly = Assembly.GetEntryAssembly(); string appDir = System.IO.Path.GetDirectoryName(assembly.Location); string dllPath = $@"{appDir}\lib\mpv-1.dll"; if (IntPtr.Size == 4) { // 32-bit } else if (IntPtr.Size == 8) { // 64-bit dllPath = $@"{appDir}\lib\mpv-1-x64.dll"; } this.InvokeIfRequired(() => { //单元测试 _player = new Mpv.NET.Player.MpvPlayer(Handle, dllPath) { Loop = true, Volume = 0 }; //防止视频黑边 _player.API.SetPropertyString("panscan", "1.0"); _player.AutoPlay = true; _player.Volume = _volume; Load(_lastPath); }); } if (string.IsNullOrEmpty(path)) { return; } _lastPath = path; _player?.Pause(); _player?.Load(path); _player?.Resume(); }