简体   繁体   English

VLC可以读取内存流吗

[英]Can VLC read a memorystream

I want to create an audio streaming server and changing the playlist dynamicly.我想创建一个音频流服务器并动态更改播放列表。 My idea to solve this problem is using libvlcsharp and just put a memorystream as media into the mediaplayer and then stream from libvlcsharp to my nginx RTMP server.我解决这个问题的想法是使用 libvlcsharp 并将内存流作为媒体放入媒体播放器,然后将 stream 从 libvlcsharp 放入我的 nginx RTMP 服务器。

Here is the code for my memorystream:这是我的内存流的代码:

new Thread(delegate (object o)
        {
            var response = WebRequest.Create("http://listen.technobase.fm/tunein-aacplus-pls").GetResponse();
            using (var stream = response.GetResponseStream())
            {
                byte[] buffer = new byte[65536];
                int read;
                while((read = stream.Read(buffer,0,buffer.Length)) > 0)
                {
                    var pos = ms.Position;
                    ms.Position = ms.Length;
                    ms.Write(buffer, 0, read);
                    ms.Position = pos;
                }
            }
        }).Start();

But the media item from libvlcsharp just don't accept a memorystream as input.但是来自 libvlcsharp 的媒体项目只是不接受内存流作为输入。 This is what I tried:这是我尝试过的:

var media = new Media(_libVLC, ms);
_mp.Play(media);

Is it feasible to put a memorystream into VLC or is there another possibility to solve this issue?将内存流放入 VLC 是否可行,或者是否有另一种可能性来解决这个问题?

Problem solved.问题解决了。

media = new Media(_libVLC, new StreamMediaInput(ms));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM