我正在尝试使用 C# 中的 MCI 播放压缩的 AVI 文件。到目前为止,我可以通过打开文件来播放它。
我打开文件的方式是这样的:
String opencommand = "open \"" + file + "\" type mpegvideo alias someMovie shareable";
int error;
error = Avi.mciSendString(opencommand, null, 0, IntPtr.Zero);
其中 file
是文件路径。这样视频播放效果很好。
如果我能够从已经使用 AVIFileOpen()
加载的流中播放它,对我来说会好得多。和来自 avifil32.dll 的 AVIFileGetStream()
。从 MSDN 文档看来我应该能够做到这一点。他们这么说here :
"MCI can open AVI files by using a file-interface pointer or a stream-interface pointer. To open a file by using either type of interface pointer, specify an at sign (@) followed by the interface pointer in place of the file or device name for the
lpszDevice
parameter. For more information about the file and stream interfaces, see "AVIFile Functions and Macros .""
但不幸的是,他们没有详细说明,我不知道我应该做什么。 “流接口(interface)指针”实际上是什么意思,我从哪里得到它?因为 MSDN 肯定不会尝试解释他们发明的术语。
最佳答案
所以部分地回答我自己的问题:接口(interface)指针的假定用法似乎是这样的:
Avi.AVIFileOpen(ref aviFile, fileName, Avi.OF_SHARE_DENY_WRITE, 0);
Avi.mciSensString("open @" + aviFile + " type mpegvideo alias someMovie", null, 0, IntPtr.Zero);
其中“aviFile”是指向由 AviFileOpen() 填充的文件接口(interface)的指针。我还尝试使用 AviFileGetStream() 获取流接口(interface)指针并将其传递给 MCI,但指针均无效,MCI 提示找不到文件。
据 MS 称,这是一个已知的问题,当然尚未解决,bug所以除了将文件路径传递给 MCI 之外,这里没有什么可做的。
关于c# - 使用MCI从内存中播放avi流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/601781/