以windows格式播放文件m3u8。 [英] Play file m3u8 in windows form.

查看:639
本文介绍了以windows格式播放文件m3u8。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的每个人,

我正在尝试为我的模块播放收音机。并抓住了流: http://210.245.60.242:1935/vov3/vov3/playlist.m3u8 [ ^ ]

但是我的模块只支持file:mp3,wav,mp2,WMP。

你能帮我解决这个问题吗?怎么样我可以玩那个流:(。

非常感谢你。



我试过的:



我尝试使用vlc和媒体播放器播放文件音频,可以播放。

Dear Everybody,
I am trying to play radio for my module. And catched stream: http://210.245.60.242:1935/vov3/vov3/playlist.m3u8[^]
But my module only supports file: mp3, wav, mp2, WMP.
So can you help me give a solution for this trouble? How the way to i can play that stream :(.
Thank you so much.

What I have tried:

I tried file audio using vlc and media player, which can play.

推荐答案

M3U [ ^ ]是一个播放列表;它是一个纯文本文件,包含表示要播放的文件的URL列表,以及可选的以



您需要阅读文件内容,提取任何网址并进行相应处理:

M3U[^] is a playlist; it's a plain-text file containing a list of URLs representing the files to play, and optionally comment lines starting with #.

You'll need to read the contents of the file, extract any URLs, and process them accordingly:
IEnumerable<Uri> LoadPlaylist(Uri source)
{
    using (var client = new WebClient())
    {
        var processedPlaylists = new HashSet<Uri>();
        var playlists = new Queue<Uri>();
        playlists.Enqueue(source);
        
        while (playlists.Count != 0)
        {
            Uri playlistUri = playlists.Dequeue();
            if (!processedPlaylists.Add(playlistUri)) continue;
            
            string playlistContent = client.DownloadString(playlistUri);
            string[] playlistLines = playlistContent.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            
            foreach (string line in playlistLines)
            {
                if (string.IsNullOrWhiteSpace(line)) continue;
                if (line[0] == '#') continue;
                
                Uri file;
                if (!Uri.TryCreate(source, line, out file))
                {
                    Console.WriteLine("Invalid line: '{0}'", line);
                    continue;
                }
            
                string extension = Path.GetExtension(file.LocalPath);
                if (extension.StartsWith(".m3u", StringComparison.OrdinalIgnoreCase))
                {
                    playlists.Enqueue(file);
                }
                else
                {
                    yield return file;
                }
            }
        }
    }
}



针对您问题中的网址运行,产生三个 .aac 文件:

高级音频编码 - 维基百科,免费的百科全书 [ ^ ]



如果您想使用该播放列表,则需要更新您的模块以支持该文件类型。


Running that against the URL in your question produces three .aac files:
Advanced Audio Coding - Wikipedia, the free encyclopedia[^]

If you want to use that playlist, then you'll need to update your module to support that file type.


这篇关于以windows格式播放文件m3u8。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆