Пример #1
0
        /*
         * /// <summary>
         * /// 获取音量。
         * /// </summary>
         * /// <param name="maxValue"></param>
         * /// <param name="minValue"></param>
         * /// <returns></returns>
         * public int waveGetVolume(int maxValue,int minValue)
         * {
         *  UInt32 d, v;
         *  d = 0;
         *  long i = LibVlcAPI.waveOutGetVolume(d, out v);
         *  UInt32 vleft = v & 0xFFFF;
         *  UInt32 vright = (v & 0xFFFF0000) >> 16;
         *
         *  int value=(int.Parse(vleft.ToString()) | int.Parse(vright.ToString())) * (maxValue - minValue) / 0xFFFF;
         *
         *  return value;
         *
         * }
         */

        /// <summary>
        /// 设置播放器全屏。
        /// </summary>
        /// <param name="control"></param>
        public void SetFullScreen(Control control, bool isFullScreen, Control control2 = null)
        {
            //获取任务栏的句柄
            //IntPtr trayHwnd = LibVlcAPI.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);
            IntPtr trayHwnd = LibVlcAPI.FindWindow("Shell_TrayWnd", null);
            //获取开始按钮句柄
            IntPtr startHwnd = LibVlcAPI.FindWindow("Button", null);

            if (isFullScreen)//全屏
            {
                //隐藏任务栏和开始按钮
                if (trayHwnd != IntPtr.Zero)
                {
                    LibVlcAPI.ShowWindow(trayHwnd, LibVlcAPI.SW_HIDE);
                }
                if (startHwnd != IntPtr.Zero)
                {
                    LibVlcAPI.ShowWindow(startHwnd, LibVlcAPI.SW_HIDE);
                }
                control.Location = new Point(0, 0);
                control.Size     = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

                if (control2 != null)
                {
                    int childWidth  = control.Size.Width / 4;
                    int childHeight = childWidth * 3 / 4;
                    control2.Size     = new Size(childWidth, childHeight);
                    control2.Location = new Point(control.Size.Width - childWidth, control.Size.Height - childHeight);
                    control2.Show();
                    //  LibVlcAPI.SetParent(control2.Handle, IntPtr.Zero);
                }
                control.Focus();// 获得焦点,否则也得不到按键
                LibVlcAPI.SetParent(control.Handle, IntPtr.Zero);
            }
            else
            {
                //显示任务栏和开始按钮
                if (trayHwnd != IntPtr.Zero)
                {
                    LibVlcAPI.ShowWindow(trayHwnd, LibVlcAPI.SW_SHOW);
                }
                if (startHwnd != IntPtr.Zero)
                {
                    LibVlcAPI.ShowWindow(startHwnd, LibVlcAPI.SW_SHOW);
                }
                control.Left = 2;
                control.Top  = 0;
                control.Size = new Size(control.Parent.Width, control.Parent.Height - 75);

                if (control2 != null)
                {
                    int childWidth  = control.Size.Width / 4;
                    int childHeight = childWidth * 3 / 4;
                    control2.Size = new Size(childWidth, childHeight);
                    // control2.Location = new Point(control.Size.Width - childWidth+2, control.Size.Height - childHeight+48 );
                    control2.Top  = control.Parent.Parent.Parent.Top + control.Parent.Parent.Parent.Height - childHeight - 86;
                    control2.Left = control.Parent.Parent.Parent.Left + control.Parent.Parent.Parent.Width - childWidth - 10;
                    control2.Show();
                    // LibVlcAPI.SetParent(control2.Handle, control.Parent.Handle);
                }
                control.Focus();// 获得焦点,否则也得不到按键
                LibVlcAPI.SetParent(control.Handle, control.Parent.Handle);
            }
        }
Пример #2
0
 public void SetFullScreen(bool istrue)
 {
     LibVlcAPI.libvlc_set_fullscreen(libvlc_media_player_, istrue ? 1 : 0);
 }
Пример #3
0
 public string Version()
 {
     return(LibVlcAPI.libvlc_get_version());
 }
Пример #4
0
 public void SetVolume(int volume)
 {
     LibVlcAPI.libvlc_audio_set_volume(libvlc_media_player_, volume);
 }
Пример #5
0
 public int GetVolume()
 {
     return(LibVlcAPI.libvlc_audio_get_volume(libvlc_media_player_));
 }
Пример #6
0
 public void SetPlayPosition(float pos)
 {
     LibVlcAPI.libvlc_media_player_set_position(libvlc_media_player_, pos);
 }
Пример #7
0
 public void SetPlayTime(double seekTime)
 {
     LibVlcAPI.libvlc_media_player_set_time(libvlc_media_player_, (Int64)(seekTime * 1000));
 }
Пример #8
0
 public double GetPlayTime()
 {
     return(LibVlcAPI.libvlc_media_player_get_time(libvlc_media_player_) / 1000.0);
 }