コード例 #1
0
        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();
        }
コード例 #2
0
        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");
            }
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        public void LoadFile(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            _lastPath = path;

            _player?.Pause();
            _player?.Load(path);
            _player?.Resume();
        }
コード例 #5
0
ファイル: MpvControl.cs プロジェクト: qin-dadie/LiveWallpaper
        public void Play(string path, bool hwdec = true, bool panscan = true)
        {
            if (_player == null)
            {
                var    assembly = Assembly.GetEntryAssembly();
                string appDir   = System.IO.Path.GetDirectoryName(assembly.Location);
                //仅使用32位
                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;

            if (panscan)
            {
                //防止视频黑边
                _player.API.SetPropertyString("panscan", "1.0");
            }
            else
            {
                _player.API.SetPropertyString("panscan", "0.0");
            }

            if (hwdec)
            {
                // 设置解码模式为自动,如果条件允许,MPV会启动硬件解码
                _player?.API.SetPropertyString("hwdec", "auto");
            }
            else
            {
                //软解,消耗cpu
                _player?.API.SetPropertyString("hwdec", "no");
            }
            //允许休眠
            _player?.API.SetPropertyString("stop-screensaver", "no");
            _player.Volume = _volume;

            _player?.Pause();
            _player?.Load(path);
            _player?.Resume();
        }
コード例 #6
0
ファイル: MpvControl.cs プロジェクト: csuffyy/LiveWallpaper
 public void Resum()
 {
     _player?.Resume();
 }