using System;
using System.Runtime.InteropServices;
namespace MyOwnPlayer
{
class MediaPlayer
{
//mediaPlayerHandle字段和属性 private MediaPlayerHandle mediaPlayerHandle;
public MediaPlayerHandle MediaPlayerHandle
{
get {
return mediaPlayerHandle; }
}
//构造方法 public MediaPlayer(MediaHandle mediaHandle,
ref ExceptionStruct ex)
{
mediaPlayerHandle = libvlc_media_player_new_from_media(mediaHandle,
ref ex);
}
//设置父窗口 public void VedioSetParent(CoreHandle coreHandle, IntPtr hDT,
ref ExceptionStruct ex)
{
libvlc_video_set_parent(coreHandle, hDT,
ref ex);
}
//播放 public void Play(
ref ExceptionStruct ex)
{
libvlc_media_player_play(mediaPlayerHandle,
ref ex);
}
//停止 public void Stop(
ref ExceptionStruct ex)
{
libvlc_media_player_stop(mediaPlayerHandle,
ref ex);
}
//Dll动态导入 [DllImport(
"libvlc")]
private static extern MediaPlayerHandle libvlc_media_player_new_from_media(MediaHandle libvlc_media_handle,
ref ExceptionStruct ex);
[DllImport(
"libvlc")]
private static extern void libvlc_video_set_parent(CoreHandle coreHandle, IntPtr hDT,
refExceptionStruct ex);
[DllImport(
"libvlc")]
private static extern void libvlc_media_player_play(MediaPlayerHandle mediaPlayerHandle,
ref ExceptionStruct ex);
[DllImport(
"libvlc")]
private static extern void libvlc_media_player_stop(MediaPlayerHandle mediaPlayerHandle,
ref ExceptionStruct ex);
}
}