Пример #1
0
 public void Dispose()
 {
     if (libVLCInstance != IntPtr.Zero)
     {
         VLCAPI.libvlc_release(libVLCInstance);
     }
 }
Пример #2
0
 public void SetRenderWindow(int wndHandle)
 {
     if (libVLCInstance != IntPtr.Zero && wndHandle != 0)
     {
         VLCAPI.libvlc_media_player_set_hwnd(libVLCMediaPlayer, wndHandle);
     }
 }
Пример #3
0
 /// <summary>
 /// 设置是否全屏
 /// </summary>
 public void SetFullScreen(bool istrue)
 {
     if (libVLCMediaPlayer != IntPtr.Zero)
     {
         VLCAPI.libvlc_set_fullscreen(libVLCMediaPlayer, istrue ? 1 : 0);
     }
 }
Пример #4
0
 public void Release()
 {
     if (libVLCMediaPlayer != IntPtr.Zero)
     {
         VLCAPI.libvlc_media_release(libVLCMediaPlayer);
     }
 }
Пример #5
0
 /// <summary>
 /// 暂停
 /// </summary>
 public void Pause()
 {
     if (libVLCMediaPlayer != IntPtr.Zero)
     {
         VLCAPI.libvlc_media_player_pause(libVLCMediaPlayer);
         playState = VLCPlayState.STATE_Pause;
     }
 }
Пример #6
0
 /// <summary>
 /// 停止
 /// </summary>
 public void Stop()
 {
     if (libVLCMediaPlayer != IntPtr.Zero)
     {
         VLCAPI.libvlc_media_player_stop(libVLCMediaPlayer);
         playState = VLCPlayState.STATE_Stop;
         StopEvent(EventArgs.Empty);
     }
 }
Пример #7
0
 /// <summary>
 /// 播放
 /// </summary>
 public void Play()
 {
     Console.WriteLine("Play");
     if (libVLCMediaPlayer != IntPtr.Zero)
     {
         if (playState != VLCPlayState.STATE_Play)
         {
             VLCAPI.libvlc_media_player_play(libVLCMediaPlayer);
             playState = VLCPlayState.STATE_Play;
         }
     }
 }
Пример #8
0
        /// <summary>
        /// 抓图(支持多种格式)
        /// </summary>
        /// <param name="savePath">完整路径(bmp,png,jpg)</param>
        /// <param name="width">抓图宽度</param>
        /// <param name="height">抓图高度</param>
        /// <returns></returns>
        public int SnapShot(string savePath, uint width = 0, uint height = 0)
        {
            int result = -1;

            if (libVLCMediaPlayer != IntPtr.Zero)
            {
                IntPtr pathPtr = VLCUtil.StringToPtr(savePath);
                result = VLCAPI.libvlc_video_take_snapshot(libVLCMediaPlayer, 0, pathPtr, width, height);
                Marshal.FreeHGlobal(pathPtr);
            }
            return(result);
        }
Пример #9
0
        /// <summary>
        /// 播放指定媒体文件
        /// </summary>
        /// <param name="filePath"></param>
        public void LoadFile(string filePath)
        {
            IntPtr libvlc_media = VLCAPI.libvlc_media_new_path(libVLCInstance, filePath);  //创建 libVLCMediaPlayer 播放核心

            if (libvlc_media != IntPtr.Zero)
            {
                VLCAPI.libvlc_media_parse(libvlc_media);
                duration = VLCAPI.libvlc_media_get_duration(libvlc_media) / 1000.0;    //获取视频时长

                VLCAPI.libvlc_media_player_set_media(libVLCMediaPlayer, libvlc_media); //将视频绑定到播放器去
                VLCAPI.libvlc_media_release(libvlc_media);

                //VLCAPI.libvlc_media_player_play(libVLCMediaPlayer);  //播放
            }
        }
Пример #10
0
        public VLCPlayer()
        {
            string pluginPath = Environment.CurrentDirectory + "\\plugins\\";  //插件目录
            string plugin_arg = "--plugin-path=" + pluginPath;

            string[] arguments = { "-I", "dummy", "--ignore-config", "--no-video-title", plugin_arg, "--avcodec-hw=dxva2" };

            libVLCInstance = VLCAPI.libvlc_new(arguments);

            //创建 libVLCMediaPlayer 播放核心
            if (libVLCInstance != IntPtr.Zero)
            {
                libVLCMediaPlayer = VLCAPI.libvlc_media_player_new(libVLCInstance);
            }
        }
Пример #11
0
 public string Version()
 {
     return(VLCAPI.libvlc_get_version());
 }