windows media player 中播放pls的方法

windows media player目前只能播放 wpl 和 asm格式的列表文件。而linux下mplayer和vlc支持的pls,很遗憾没法支持。

不过,老外写了个“open pls in wmp”的插件,安装后就可以播放了。就是这个OpenPlsInWmp2Setup.exe

http://openplsinwmp.codeplex.com/

看起来挺酷,不过看一下代码就知道原理很简单。

using System;
using System.IO;

namespace Jon.Galloway.Wrote.Me
{
    class OpenPlsInWM
    {
        [STAThread]
        static void Main(string[] args)
        {
            if (args.GetUpperBound(0) > -1)
            {
                string filename = args[0];
                using (StreamReader sr = new StreamReader(filename)) 
                {
                    string line;
                    while ((line = sr.ReadLine()) != null) 
                    {
                        if (line.ToLower().StartsWith("file1="))
                        {
                            string url = line.Split('=')[1];
                            System.Diagnostics.Process.Start("wmplayer.exe",url);
                            break;
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("Usage: OpenPlsInWM "playlist.pls"");
                Console.WriteLine("Associate PLS file extension with this application to allow Windows Media Player to play them.");
            }
        }
    }
}


因为pls文件格式非常简单, 每行读取到目标文件名后,调用wmplayer.exe来触发就可以了。

所以说,这个只能windows media player本身使用。如果是IE嵌入的windows media player播放器还是用不起来。

特说明一下。

原文地址:https://www.cnblogs.com/riskyer/p/3241626.html