vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】

时间:2022-09-20 00:16:15
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll
2008-12-03 17:38:46
标签: WinForm  C#  libvlc.dll  休闲  vlc
原创作品,允许转载,转载时请务必以超链接形式标明文章  原始出处 、作者信息和本声明。否则将追究法律责任。 http://jeremiah.blog.51cto.com/539865/116981
    vlc-0.9.4提供的libvlc.dll是可以动态调用的,Jeremiah这一篇博客就介绍下如何用C#和WinForm框架调用libvlc.dll作个简易播放器。
 
    1. vs2005新建工程,将vlc-0.9.4的libvlc.dll,libvlccore.dll,plugins目录全部拷贝到工程目录下面\bin\Debug中
 
    2. 创建异常结构体
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System.Collections.Generic; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System.Text; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】namespace MyOwnPlayer 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】         //异常结构体 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】         public  struct ExceptionStruct 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 private  int raised; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 private  int code; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 private  string message; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】         class MediaException 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】}
 
    3. CoreHandle和Core类
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System.Runtime.InteropServices; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】namespace MyOwnPlayer 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】         class CoreHandle : SafeHandle 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //构造方法 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 public CoreHandle() 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        :  base(IntPtr.Zero,  true
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //重写的方法 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 public  override  bool IsInvalid 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        get {  return handle == IntPtr.Zero; } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 protected  override  bool ReleaseHandle() 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                         if (!IsInvalid) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                                libvlc_release( this); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                                handle = IntPtr.Zero; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                         return  true
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 protected  override  void Dispose( bool disposing) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        ReleaseHandle(); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                         base.Dispose(disposing); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //Dll动态导入 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                [DllImport( "libvlc")] 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 private  static  extern  void libvlc_release(CoreHandle coreHandle); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System.Runtime.InteropServices; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】namespace MyOwnPlayer 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        class Core 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                //coreHandle字段和属性 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                private CoreHandle coreHandle; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                public CoreHandle CoreHandle 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        get { return coreHandle; } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                //构造方法 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                public Core(string[] argv, ref ExceptionStruct ex) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        coreHandle = libvlc_new(argv.Length, argv, ref ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                //Dll动态导入 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                [DllImport("libvlc")] 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                private static extern CoreHandle libvlc_new(int argc, string[] args, ref ExceptionStruct ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
 
    3. MediaHandle和Media类,注意里面的非英文路径处理方法。
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System.Runtime.InteropServices; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】namespace MyOwnPlayer 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        class MediaHandle : SafeHandle 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                //构造方法 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                public MediaHandle() 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        : base(IntPtr.Zero, true
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                //重写的方法 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                public override bool IsInvalid 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        get { return handle == IntPtr.Zero; } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                protected override bool ReleaseHandle() 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        if (!IsInvalid) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                                libvlc_media_release(this); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                                handle = IntPtr.Zero; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        return true
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                protected override void Dispose(bool disposing) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        ReleaseHandle(); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        base.Dispose(disposing); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                //Dll动态导入 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                [DllImport("libvlc")] 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                private static extern void libvlc_media_release(MediaHandle mediaHandle);                 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System.Text; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System.Runtime.InteropServices; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】namespace MyOwnPlayer 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】         class Media 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //mediaHandle字段和属性 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 private MediaHandle mediaHandle; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 public MediaHandle MediaHandle 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        get {  return mediaHandle; } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //构造方法                
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 public Media(CoreHandle coreHandle, String filename,  ref ExceptionStruct ex) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                         //c#为UTF-16编码, libvlc.dll为UTF-8编码, 需要转换. 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        UTF8Encoding utf8 =  new UTF8Encoding(); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        mediaHandle = libvlc_media_new(coreHandle, utf8.GetBytes(filename),  ref ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //Dll动态导入 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                [DllImport( "libvlc")] 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 private  static  extern MediaHandle libvlc_media_new 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        (CoreHandle coreHandle, [MarshalAs(UnmanagedType.LPArray)]  byte[] link,  refExceptionStruct ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
 
    5. MediaPlayerHandle和MediaPlayer类
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System.Runtime.InteropServices; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】namespace MyOwnPlayer 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】         class MediaPlayerHandle : SafeHandle 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //构造方法 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 public MediaPlayerHandle() 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        :  base(IntPtr.Zero,  true
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //重写的方法 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 public  override  bool IsInvalid 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        get {  return handle == IntPtr.Zero; } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 protected  override  bool ReleaseHandle() 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                         if (!IsInvalid) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                                libvlc_media_player_release(this); vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                                handle = IntPtr.Zero; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                         return  true
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 protected  override  void Dispose( bool disposing) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        ReleaseHandle(); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                         base.Dispose(disposing); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //Dll动态导入 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                [DllImport( "libvlc")] 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 private  static  extern  void libvlc_media_player_release(MediaPlayerHandle mediaPlayerHandle); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】using System.Runtime.InteropServices; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】namespace MyOwnPlayer 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】         class MediaPlayer 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //mediaPlayerHandle字段和属性 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 private MediaPlayerHandle mediaPlayerHandle; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 public MediaPlayerHandle MediaPlayerHandle 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        get {  return mediaPlayerHandle; } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //构造方法 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 public MediaPlayer(MediaHandle mediaHandle,  ref ExceptionStruct ex) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        mediaPlayerHandle = libvlc_media_player_new_from_media(mediaHandle,  ref ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //设置父窗口 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 public  void VedioSetParent(CoreHandle coreHandle, IntPtr hDT,  ref ExceptionStruct ex) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        libvlc_video_set_parent(coreHandle, hDT,  ref ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //播放 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 public  void Play( ref ExceptionStruct ex) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        libvlc_media_player_play(mediaPlayerHandle,  ref ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //停止 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 public  void Stop( ref ExceptionStruct ex) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                { 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                        libvlc_media_player_stop(mediaPlayerHandle,  ref ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 //Dll动态导入 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                [DllImport( "libvlc")] 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 private  static  extern MediaPlayerHandle libvlc_media_player_new_from_media(MediaHandle libvlc_media_handle,  ref ExceptionStruct ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                [DllImport( "libvlc")] 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 private  static  extern  void libvlc_video_set_parent(CoreHandle coreHandle, IntPtr hDT,  refExceptionStruct ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                [DllImport( "libvlc")] 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 private  static  extern  void libvlc_media_player_play(MediaPlayerHandle mediaPlayerHandle,  ref ExceptionStruct ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                [DllImport( "libvlc")] 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】                 private  static  extern  void libvlc_media_player_stop(MediaPlayerHandle mediaPlayerHandle,  ref ExceptionStruct ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        } 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
 
    6. 基本工作做好了。下一步建立一个Form,里面画一个Panel(播放容器),画一个Textbox(播放地址),画一个Button(播放按钮),Button的点击事件为:
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】private void button1_Click(object sender, EventArgs e) 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        
//要播放的文件的uri 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        
string uri = this.textBox1.Text; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        
 //进行播放的控件的句柄 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        IntPtr hdl = 
this.panel1.Handle; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        
 //播放参数 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        
string[] argv = new string[] { "-I""--ignore-config" }; 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        
 //vlc对象的创建 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        ExceptionStruct ex = 
new ExceptionStruct(); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        Core core = 
new Core(argv, ref ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        Media media = 
new Media(core.CoreHandle, uri, ref ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        MediaPlayer player = 
new MediaPlayer(media.MediaHandle, ref ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        
 //垃圾回收 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        GC.Collect(); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        
 //播放 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        player.VedioSetParent(core.CoreHandle, hdl, 
ref ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        player.Play(ref ex); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        
 //继续回收垃圾等相关操作 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        GC.Collect(); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】        GC.WaitForPendingFinalizers(); 
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】}
 
    7. 基本的播放功能就是这样实现的。其他接口请参考源码下面的\include\vlc\libvlc.h文件,里面有比较详细的对外接口的说明。
 
    8. 以上代码已经发送到附件中(MyOwnPlayer.rar),参考网址的楼主写的代码也在附件中(Marx_libvlc_wrapper(2).zip)。调试附件请注意第1步。
   
参考网址:

本文出自 “海狗哥的流媒体空间” 博客,请务必保留此出处http://jeremiah.blog.51cto.com/539865/116981

vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】   vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】 lbp0200、xc_shen、jiang421122
8人
了这篇文章

附件下载:
   vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】Marx_libvlc_wrapper(2).zip
   vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】MyOwnPlayer.rar
类别: VLC┆阅读( 26800)┆评论(80) ┆ 返回博主首页返回博客首页