在 Linux 终端收听广播
MPlayer

> 
> MPlayer 是一个多功能的开源媒体播放器，它在 Linux 命令行中非常有用。
> 
> 
> 


![](/data/attachment/album/201812/29/113239cii055al7hnsx764.png)


你已经看到我们为期 24 天的 Linux 命令行玩具日历。如果这是你第一次访问该系列，你可能会问自己什么是命令行玩具。它可能是一个游戏或任何简单的消遣，可以帮助你在终端玩得开心。


你们中的一些人之前已经看过我们日历中的各种玩具，但我们希望每个人至少见到一件新玩具。


在命令行中有很多方法可以听音乐。如果你有本地存储的媒体，`cmus` 是一个很好的选择，但还有[很多其他选择](https://opensource.com/life/16/8/3-command-line-music-players-linux)。


不过，很多时候，当我在终端的时候，我会走神并且不会注意挑选每首歌，并让其他的来做。虽然为了这个我有很多播放列表，但过了一段时间，即使过时，我也会切换到互联网电台。


今天的玩具，MPlayer，是一个多功能的多媒体播放器，几乎可以支持任何你给它的媒体格式。如果尚未安装 MPlayer，你可能会发现它已在你的发行版中打包。在 Fedora 中，我在 [RPM Fusion](https://rpmfusion.org/) 中找到了它（请注意，这不是 Fedora 的“官方”仓库，因此请谨慎操作）：



```
$ sudo dnf install mplayer
```

MPlayer 有一系列命令行选项可根据你的具体情况进行设置。我想听 Raleigh 当地的大学广播电台（[88.1 WKN](https://wknc.org/index.php)，这个很棒！），在它们的网站得到流媒体网址之后，像这样就可以让收音机运行了，不需要 GUI 或 Web 播放器：



```
$ mplayer -nocache -afm ffmpeg http://wknc.sma.ncsu.edu:8000/wknchd1.mp3
```

MPlayer 是 GPLv3 许可证下的开源软件，你可以从项目的[网站](http://www.mplayerhq.hu/)中找到更多关于项目的信息并下载源代码。


正如我在昨天的文章中提到的，我试图使用每个玩具的截图作为每篇文章的主图，但是当进入音频世界时，我不得不稍微改改。所以今天的图像是由 **libcaca** 包中的 **img2txt** 绘制的来自公共域的无线电塔图标。


你有特别喜欢的命令行小玩具需要我介绍的吗？我们的日历基本上是为这个系列剩余的玩具设置的，但我们仍然很想在新的一年里推出一些很酷的命令行玩具。评论告诉我，我会查看的。如果还有空位置，我会考虑介绍它的。并让我知道你对今天的玩具有何看法。


一定要看看昨天的玩具，[让你的 Linux 终端说出来](https://opensource.com/article/18/12/linux-toy-espeak)，明天记得回来！




---


via: <https://opensource.com/article/18/12/linux-toy-mplayer>


作者：[Jason Baker](https://opensource.com/users/jason-baker) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
You've found your way to our 24-day-long Linux command-line toys advent calendar. If this is your first visit to the series, you might be asking yourself what a command-line toy even is. It could be a game or any simple diversion that helps you have fun at the terminal.

Some of you will have seen various selections from our calendar before, but we hope there’s at least one new thing for everyone.

There are many ways to listen to music at the command line; if you've got media stored locally, **cmus** is a great option, but there are [plenty of others](https://opensource.com/life/16/8/3-command-line-music-players-linux) as well.

Lots of times when I'm at the terminal, though, I'd really rather just zone out and not pay close attention to picking each song, and let someone else do the work. While I've got plenty of playlists that work for just such a purpose, after a while, even though go stale, and I'll switch over to an internet radio station.

Today's toy, MPlayer, is a versatile multimedia player that will support just about any media format you throw at it. If MPlayer is not already installed, you can probably find it packaged for your distribution. On Fedora, I found it in [RPM Fusion](https://rpmfusion.org/) (be aware that this is not an "official" repository for Fedora, so exercise caution):

`$ sudo dnf install mplayer`


MPlayer has a slew of command-line options to set depending on your situation. I wanted to listen to the local college radio station here in Raleigh ([88.1 WKNC,](https://wknc.org/index.php) they're pretty good!), and so after grabbing the streaming URL from their website, all that took to get my radio up and running, no GUI or web player needed, was:

`$ mplayer -nocache -afm ffmpeg http://wknc.sma.ncsu.edu:8000/wknchd1.mp3`


MPlayer is open source under the GPLv3, and you can find out more about the project and download source code from the project's [website](http://www.mplayerhq.hu/).

As I mentioned in yesterday's article, I'm trying to use a screenshot of each toy as the lead image for each article, but as we moved into the world of audio, I had to fudge it a little. So today's image was created from a public domain icon of a radio tower using **img2txt**, which is provided by the **libcaca** package.

Do you have a favorite command-line toy that you we should have included? Our calendar is basically set for the remainder of the series, but we'd still love to feature some cool command-line toys in the new year. Let me know in the comments below, and I'll check it out. And let me know what you thought of today's amusement.

Be sure to check out yesterday's toy, [Let you Linux terminal speak its mind](https://opensource.com/article/18/12/linux-toy-espeak), and come back tomorrow for another!

## 5 Comments