private void OpenPlayer()
{
IntPtr hwnd = this.Panel1.Handle;
PlayerSDK.PLAYER_INIT_PARAMS di = new PlayerSDK.PLAYER_INIT_PARAMS();
di.audio_bufpktn = 10;
di.video_bufpktn = 10;
di.init_timeout = 2000;
di.auto_reconnect = 2000;
di.rtsp_transport = 0;
di.video_thread_count = 1;
di.vdev_render_type = 1;
di.video_hwaccel = 1;
GCHandle C_di = GCHandle.Alloc(di, GCHandleType.Pinned);
// 运行到此处会弹出异常
mPlayer = PlayerSDK.player_open(playurl, hwnd, C_di.AddrOfPinnedObject());
PlayerSDK.player_play(mPlayer);
C_di.Free();
}
// PlayerSDK 的函数定义
public class PlayerSDK
{
[DllImport(@"playerdll\fanplayer.dll", EntryPoint = "player_open")]
public static extern IntPtr player_open(string file, IntPtr hwnd, IntPtr configs);
[DllImport(@"playerdll\fanplayer.dll", EntryPoint = "player_close")]
public static extern void player_close(IntPtr player);
[DllImport(@"playerdll\fanplayer.dll", EntryPoint = "player_play")]
public static extern void player_play(IntPtr player);
[DllImport(@"playerdll\fanplayer.dll", EntryPoint = "player_pause")]
public static extern void player_pause(IntPtr player);
[DllImport(@"playerdll\fanplayer.dll", EntryPoint = "player_seek")]
public static extern void player_seek(IntPtr player, long ms);
[DllImport(@"playerdll\fanplayer.dll", EntryPoint = "player_setrect")]
public static extern void player_setrect(IntPtr player, int type, int x, int y, int w, int h);
[DllImport(@"playerdll\fanplayer.dll", EntryPoint = "player_snapshot")]
public static extern int player_snapshot(IntPtr player, string file, int w, int h, int wait);
[DllImport(@"playerdll\fanplayer.dll", EntryPoint = "player_setparam")]
public static extern void player_setparam(IntPtr player, uint id, IntPtr param);
[DllImport(@"playerdll\fanplayer.dll", EntryPoint = "player_setparam")]
public static extern void player_setparam(IntPtr player, uint id, ref int param);
[DllImport(@"playerdll\fanplayer.dll", EntryPoint = "player_getparam")]
public static extern void player_getparam(IntPtr player, uint id, ref long param);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PLAYER_INIT_PARAMS
{
public int video_vwidth;
public int video_vheight;
public int video_owidth;
public int video_oheight;
public int video_frame_rate;
public int video_stream_total;
public int video_stream_cur;
public int video_thread_count;
public int video_hwaccel;
public int video_deinterlace;
public int video_rotate;
public int video_codecid;
public int video_bufpktn;
public int audio_channels;
public int audio_sample_rate;
public int audio_stream_total;
public int audio_stream_cur;
public int audio_bufpktn;
public int subtitle_stream_total;
public int subtitle_stream_cur;
public int vdev_render_type;
public int adev_render_type;
public int init_timeout;
public int open_syncmode;
public int auto_reconnect;
public int rtsp_transport;
public int avts_syncmode;
public char filter_string;
public char ffrdp_tx_key;
public char ffrdp_rx_key;
}
}
作者好,我的C#程序在调用 player_open 的时候弹出了异常,但我不清楚这个异常是由什么导致的,能不能帮忙分析下原因?