最新评论
@OK磊
嗯,这个知道,会在后续的版本改善,也可以直接禁用横竖屏,只让横屏播放。
博主,不知道你有没有发现,vitamio 在播放视频的时候通过不断的横竖屏切换,画面会变形(第一篇播放月亮那个视频,可以看下)。
@tjyzhy
您好,无法在模拟器使用,真机测试会提醒安装vitamio
编译文件后执行,报错如下请博主看下:
vitamio is not compatible with your device.
Re:Android中文翻译组 - 简介 单骥行 2012-06-01 14:58
排队 致敬
[quote]Nina_HY:谢谢农民伯伯,每次看到你的博客总觉得如梦初醒。[/quote]
我也是同样的感觉。。。
Re:Android中文翻译组 - 简介 xc# 2012-05-31 17:40
向你们致敬!!!多谢啦!
.net学习交流群140126394,欢迎加入一起学习、交流
[quote]libailibai:
实在太感谢了啊,帮了我大忙,原先我也是把gridview定义在非main.xml里面,结果用
GridView gridview = (GridView)layout.findViewById(R.id.gridview);
然后gridview.setAdapter(new ImageAdapter(ViewTestsActivity.this));
系统一直报错。
看到你的inflate,恍然大悟
[/quote]
我也是啊,刚学android,这个问题困扰了我N天了,太感谢了,楼主!!1
结合以上的思路,我使用Marshal类来代替以上的unsafe代码。
问题好像解决了部分,我可以看到第一行要显示的OSD文字了,但接着问题又出现:
System.Runtime.InteropServices.COMException (0x80070006): 句柄无效。 (Exception from HRESULT: 0x80070006 (E_HANDLE))
真是一波三折,楼主救命 :(...
代码如下:
思路:
取二维数组每一维的首地址给ptr[i],然后在取数组ptr的地址给pt,然后再传给SetOsdDisplayModeEx
封装:
[DllImport("DS40xxSDK.dll")]
public static extern int SetOsdDisplayModeEx(IntPtr hChannelHandle, int Brightness, bool Translucent, int param, int nLineCount, IntPtr Format);
调用:
public bool SetOSD()
{
ushort[,] Format = new ushort[ + 1, + 1] {
{
16,
16,
'A',
'\0'
},
{
16,
32,
'B',
'\0'
}
};
int row = Format.GetUpperBound(0) + 1;
int col = Format.GetUpperBound(1) + 1;
IntPtr pt = new IntPtr();
IntPtr[] ptr = new IntPtr[row];
//申请内存
pt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * row);
for (int i = 0; i <= row - 1; i++) {
//ptr(i) = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(UShort)) * col)
ptr[i] = Marshal.UnsafeAddrOfPinnedArrayElement(Format, i);
}
Marshal.Copy(ptr, 0, pt, row);
int ret1 = HKDSSDK.HikVisionSDK.SetOsdDisplayModeEx(ChannelHandle, 255, false, 0x10200, 2, pt);
int ret2 = -1;
bool retval = false;
if (ret1 == 0) {
ret2 = HKDSSDK.HikVisionSDK.SetOsd(ChannelHandle, true);
if (ret2 == 0) {
retval = true;
} else {
retval = false;
}
} else {
retval = false;
}
for (int i = 0; i <= row - 1; i++) {
Marshal.FreeHGlobal(ptr[i]);
}
Marshal.FreeHGlobal(pt);
return retval;
}
调用结果:
看到画面上有我二维数组中Format[0,*]的值'A',
然后就报错:
System.Runtime.InteropServices.COMException (0x80070006): 句柄无效。 (Exception from HRESULT: 0x80070006 (E_HANDLE))
农民伯伯。
我遇到一个问题,我的流媒体客户端无法访问硬盘录像机的IP通道。
rtsp://192.168.0.19/192.168.0.241:8000:HIK-DS8000HC:通道号:0:admin:12345/av_stream
通道号写成0-15(模拟通道)都可以。但是预览的画面是花的。
我该怎么写才能连接到IP通道呢。
本来准备参照您的博客写server这些的,但是没找到hikserver.dll
上面代码是从其它地方七拼八凑来的,然后自己改的,有些混乱。
虽然实现了,但还是不希望用非托管的代码来实现,楼主能否也帮忙想一想。
终于有进展,用了Unsafe的方法,使用指针对照C++的源代码实现了一下,居然成功了,但还是想使用“安全”的方案来做,不知道LZ有没有办法。
代码如下,
封装部分:
public static extern unsafe int SetOsdDisplayModeEx(IntPtr hChannelHandle, int Brightness, bool Translucent, int param, int nLineCount, ushort*[] Format);
调用:
ushort[,] Format = {
{
48,
16,
'A',
'\0'
},
{
48,
32,
'B',
'\0'
}
};
//IntPtr pt;
//pt = Marshal.AllocHGlobal(8);
//Marshal.Copy(Format, 0, pt, 8);
//DS40xxSDK.HikVisionSDK.SetOsdDisplayModeEx(ChannelHandle, 255, true, 0, 2, pt);// (ChannelHandle, 255, true, 0, Format1, Format2);
this.UsePoint(Format);
DS40xxSDK.HikVisionSDK.SetOsd(ChannelHandle, true);
使用指针非安全代码方法:
int UsePoints(ushort[,] Format)
{
int row = Format.GetUpperBound(0) + 1;
int col = Format.GetUpperBound(1) + 1;
unsafe
{
fixed (ushort* fp = Format)
{
ushort*[] farr = new ushort*[row];
for (int i = 0; i < row; i++)
{
farr[i] = fp + i * col;
}
return DS40xxSDK.HikVisionSDK.SetOsdDisplayModeEx(ChannelHandle, 255, true, 0, 2, farr);
}
}
}
@奔跑在路上
直接使用自定义View是没有问题的,但是不能强制类型转换,不知道是否可以通过反射来调用自定义View的方法,你可以试试看。