• 7287阅读
  • 3回复

C#调用APlayerCaller完成API创建,问题求助! [复制链接]

上一主题 下一主题
离线晨曦
 

只看楼主 倒序阅读 使用道具 楼主  发表于: 2015-03-21
APlayerCaller.dll创建基本已写,创建依然失败。请求帮助。
出错图:



// button1 事件是创建
// 事件写在按钮下后才发现,只要创建后就会程序意外结束!
  1. //Form1.cs 部分代码
  2. public delegate void fun3(int l1, int l2, int l3);//声明委托
  3.        private void button1_Click(object sender, EventArgs e)
  4.         {
  5.            // new 方法并取地址,以下方同。
  6.             fun3 DOnMessage = new fun3(OnMessage);
  7.             POnMessage = Marshal.GetFunctionPointerForDelegate(DOnMessage);
  8.             fun2 DOnStateChanged = new fun2(OnStateChanged);
  9.             POnStateChanged = Marshal.GetFunctionPointerForDelegate(DOnStateChanged);
  10.             fun0 DOnOpenSuccess = new fun0(OnOpenSuccess);
  11.             POnOpenSuccess = Marshal.GetFunctionPointerForDelegate(DOnOpenSuccess);
  12.             fun1 DOnSeekCompleted = new fun1(OnSeekCompleted);
  13.             POnSeekCompleted = Marshal.GetFunctionPointerForDelegate(DOnSeekCompleted);
  14.             fun1 DOnBuffer = new fun1(OnBuffer);
  15.             POnBuffer = Marshal.GetFunctionPointerForDelegate(DOnBuffer);
  16.             fun0 DOnVideoSizeChanged = new fun0(OnVideoSizeChanged);
  17.             POnVideoSizeChanged = Marshal.GetFunctionPointerForDelegate(DOnVideoSizeChanged);
  18.             funs1 DOnDownloadCodec = new funs1(OnDownloadCodec);
  19.             POnDownloadCodec = Marshal.GetFunctionPointerForDelegate(DOnDownloadCodec);
  20.             fun2 DOnEvent = new fun2(OnEvent);
  21.             POnEvent = Marshal.GetFunctionPointerForDelegate(DOnEvent);
  22.             
  23.             //创建代码
  24.             HAplayer = APlayer.APlayer.CreateAPlayer(panel1.Handle.ToInt32(), 50, 50, 200, 200, (long)POnMessage, (long)POnStateChanged, (long)POnOpenSuccess, (long)POnSeekCompleted, (long)POnBuffer, (long)POnVideoSizeChanged, (long)POnDownloadCodec, (long)POnEvent);      
  25.             MessageBox.Show("句柄是:" + HAplayer.ToString());
  26.             //APlayer.APlayer.open(HAplayer, "F:\\视频\\C体.BD1280超清国英双语特效中英双字.mp4");
  27.         }
  28. //回调方法
  29. void OnMessage(int l1, int l2, int l3)
  30.         {
  31.               //方法体
  32.         }
  1. // Aplayer.cs 部分代码
  2. using System;
  3. using System.Text;
  4. using System.Diagnostics;
  5. using System.Runtime.InteropServices;
  6. namespace APlayer
  7. {
  8.     public abstract class APlayer
  9.     {
  10.         [DllImportAttribute("APlayerCaller.dll", EntryPoint = "APlayer_Create")]
  11.         public static extern int CreateAPlayer
  12.         (
  13.             long hParent,
  14.             long x,
  15.             long y,
  16.             long nWidth,
  17.             long nHeight,
  18.             long OnMessage,
  19.             long OnStateChanged,
  20.             long OnOpenSuccess,
  21.             long OnSeekCompleted,
  22.             long OnBuffer,
  23.             long OnVideoSizeChanged,
  24.             long ondownloadcodec,
  25.             long OnEvent
  26.         );
  27.     }
  28. }

// Debug主程序目录已经放置文件


// 求助解决,实在头疼。





离线晨曦

只看该作者 沙发  发表于: 2015-03-21
出错图:
[attachment=425] 图片补上

// Debug主程序目录已经放置文件
[attachment=426] 图片补上


本机已用易语言测试过,C#嵌入COM组件(aplayer控件)都一切正常。求助!
等待回复...

本帖提到的人: @aplayer @932966089
离线xushen

只看该作者 板凳  发表于: 2015-03-22
是很难啊。。。。。。。。。。。。。。。。。。。。。。。
http://www.huankv.com/
离线aplayer

只看该作者 地板  发表于: 2015-03-23
对照 APlayerCaller.dll 的源代码(论坛有下),检查各个事件响应函数参数的数目和数据类型是否有不一致的,很有可能是这个问题导致的崩溃。
快速回复
限100 字节
如果您提交过一次失败了,可以用”恢复数据”来恢复帖子内容
 
上一个 下一个