问题描述
我想像这样使用LibVLC从内存流中播放媒体文件:
I want to play a media file from a memory stream using LibVLC like so:
//Ideally it would go like this:
LibVLC.MediaFromStream = new MemoryStream(File.ReadAllBytes(File_Path));
当然,这是我想要的东西的非常简化的版本,但希望它能传达我想要的东西.
Of course this is a very oversimplified version of what I want but hopefully it conveys what I am looking for.
原因是我希望自己所做的事情具有足够的可移植性,而不必跟踪文件位置等.我宁愿在一个可以读取的单个文件中拥有大量数据,也不必跟踪一个或多个文件的位置.
The reason being that I want there to be a good amount of portability for what I'm doing without having to track file locations and such. I'd rather have a massive clump of data in a single file that can be read from than have to track the locations of one or many more files.
我知道这与LibVLC IMEM Access模块有关.但是,看看我能从中找到什么信息,我感觉自己已经从飞机上摔下来,只有几分钟的时间学习如何飞行,然后再着陆.
I know this has something to do with the LibVLC IMEM Access module. However, looking at what information I've been able to find on that, I feel like I've been tossed from a plane and have just a few minutes to learn how to fly before I hit the ground.
推荐答案
在此处查看我对类似问题的回答: https://stackoverflow.com/a/31316867/2202445
See my answer to a similar question here:https://stackoverflow.com/a/31316867/2202445
总而言之,API:
libvlc_media_t* libvlc_media_new_callbacks (libvlc_instance_t * instance,
libvlc_media_open_cb open_cb,
libvlc_media_read_cb read_cb,
libvlc_media_seek_cb seek_cb,
libvlc_media_close_cb close_cb,
void * opaque)
允许这样做.尽管文档指出搜索回调并非总是必需的,但必须实现这四个回调,请参见 libVlc文档.我在上面的答案中给出了部分实现的示例.
allows just this. The four callbacks must be implemented, although the documentation states the seek callback is not always necessary, see the libVlc documentation. I give an example of a partial implementation in the above answer.
这篇关于如何将内存流加载到LibVLC中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!