I enjoy listening to Code Radio while I'm working. The music helps me focus and block out the noise of the surrounding office.
我在工作时喜欢听Code Radio 。 音乐可以帮助我集中注意力并阻挡周围办公室的噪音。
But when one of my co-workers interrupts my flow to ask a question, I have to switch Code Radio off.
但是,当我的一位同事打断我的流程来提问时,我必须关闭Code Radio。
It's kind of time consuming to switch over to the Code Radio site to pause the music. You have to figure out which tab Code Radio is playing in so you can pause it.
切换到Code Radio网站以暂停音乐是很耗时的。 您必须弄清楚Code Radio正在播放哪个标签,以便您可以暂停它。
To overcome this situation, I started opening a separate browser that I only used for playing Code Radio. This made it easier for me since I could just alt+tab back to that browser icon and press Code Radio's spacebar hotkey to pause the music.
为了克服这种情况,我开始打开一个单独的浏览器,该浏览器仅用于播放Code Radio。 这使我更轻松,因为我可以alt + tab键回到该浏览器图标,然后按Code Radio的空格键热键暂停音乐。
But running a separate browser only for playing music felt like a drain on my computer resources. I thought there would be a better solution that wasn't so taxing.
但是只运行一个单独的浏览器来播放音乐感觉就像是在消耗我的计算机资源。 我认为会有更好的解决方案,而不是那么费力。
Since, I started listening to Code Radio, I had largely abandoned Spotify and uninstalled the app. But I remembered how when I used to use Spotify, I was could use the media controls on my keyboard to pause and play the music. This got me thinking.
自从我开始收听Code Radio以来,我基本上放弃了Spotify并卸载了该应用程序。 但是我记得当我以前使用Spotify的时候可以使用键盘上的媒体控件来暂停和播放音乐。 这让我开始思考。
更优雅的解决方案 (A more elegant solution)
What if you could play and pause Code Radio with a single hotkey on your keyboard - even if you were in your terminal or your code editor?
如果您可以使用键盘上的单个热键来播放和暂停Code Radio,即使您在终端机或代码编辑器中,该怎么办?
Well you can't do that with a browser app. But you can do that with a native app running on your computer. And you may already have this app installed on your computer. It's called VLC, and it's one of the most common media players.
好吧,您无法通过浏览器应用程序做到这一点。 但是,您可以通过在计算机上运行的本机应用程序来做到这一点。 并且您可能已经在计算机上安装了此应用程序。 它称为VLC,是最常见的媒体播放器之一。
During my lunch break, I kept thinking on how to make it easy for myself to listen to music and have the ability to play/pause music from my keyboard with the click of a single button i.e. play/pause button. So, I searched in the internet and found out that media players can stream content from any network.
在午休时间,我一直在思考如何使自己更容易听音乐,并能够通过单击单个按钮(即播放/暂停按钮)从键盘上播放/暂停音乐。 因此,我在互联网上进行搜索,发现媒体播放器可以流式传输来自任何网络的内容。
This article helped me understand how to stream content from any network in VLC.
本文帮助我了解了如何在VLC中从任何网络流式传输内容。
In order to have the flexibility of using the play/pause button from my keyboard I had to use a media player. I found the VLC media player a reliable media player that is available in all platforms and it is open source and free to download.
为了灵活使用键盘上的“播放/暂停”按钮,我不得不使用媒体播放器。 我发现VLC媒体播放器是一种可靠的媒体播放器,可在所有平台上使用,它是开源的,可以免费下载。
In my first attempt, I tried to open the Code Radio website page URL: https://radio.freecodecamp.org in VLC media player.
在我的第一次尝试中,我尝试在VLC媒体播放器中打开Code Radio网站页面URL: https ://radio.freecodecamp.org。
And VLC media player could not play it. I tried pressing the play button multiple times, but it did not nothing.
VLC媒体播放器无法播放。 我尝试多次按播放按钮,但并非一无所获。
After multiple trials, I found that VLC media player requires a music format file (e.g. mp3) and cannot parse the html website :/. the URL needs to be the location of the music format file.
经过多次试验,我发现VLC媒体播放器需要音乐格式的文件(例如mp3),并且无法解析html网站:/。 URL必须是音乐格式文件的位置。
So I went back to the Code Radio music website page and inspected the website page. I searched for "mp3" keyword and found nothing.
因此,我回到了Code Radio音乐网站页面并检查了该网站页面。 我搜索了“ mp3 ”关键字,却一无所获。
Then I noticed i did not hit the play button for the website to request for the mp3 file to be played. I just tried it (on Firefox), and I don't have to click enter to find the URL of those mp3s.
然后,我注意到我没有点击网站的播放按钮以请求播放mp3文件。 我刚刚尝试过(在Firefox上),而不必单击Enter即可找到那些mp3的URL。
There are two bitrate options available on Code Radio music website page.
Code Radio音乐网站页面上有两个比特率选项。
The mp3 files I saw in the inspect correspond to the bitrate option button.
我在检查中看到的mp3文件对应于bitrate选项按钮。
The two bitrates and their file names:
这两个比特率及其文件名:
- 64kbps - low.mp3 64kbps-low.mp3
- 128kbps - radio.mp3 128kbps-radio.mp3
In my second attempt, I used the mp3 file location URL: https://coderadio-admin.freecodecamp.org/radio/8010/radio.mp3?1564340326 which I found in the Code Radio music page in the VLC media player. It started to play the music :).
在第二次尝试中,我使用了mp3文件的位置URL: https : //coderadio-admin.freecodecamp.org/radio/8010/radio.mp3?1564340326 ,该URL是在VLC媒体播放器的“代码广播”音乐页面中找到的。 它开始播放音乐:)。
I noticed the unique number at the end of the mp3 file "?1564340326". This seem to be unique values created by the back-end server. When I opened the VLC media player in the next day. It was unable to play the Code Radio music. I tried to delete the last values at the end of the mp3 file and it started to play again :).
我注意到mp3文件“ ?1564340326 ”结尾处的唯一编号。 这似乎是后端服务器创建的唯一值。 第二天我打开VLC媒体播放器时。 它无法播放Code Radio音乐。 我试图删除mp3文件末尾的最后一个值,并且它再次开始播放:)。
从VLC媒体播放器播放Code Radio音乐的步骤 (Steps to play Code Radio music from VLC media player)
Step 1. Open VLC media player. Then, click on File->Open Network
步骤1.打开VLC媒体播放器。 然后,单击文件 -> 打开网络
Step 2. In the URL field, paste this URL: https://coderadio-admin.freecodecamp.org/radio/8010/radio.mp3 . Then Click on the Open button.
步骤2.在“ URL”字段中, 粘贴以下网址: https : //coderadio-admin.freecodecamp.org/radio/8010/radio.mp3 。 然后单击“ 打开”按钮。
Then, VLC media player will open the Code Radio network and start playing the music.
然后, VLC媒体播放器将打开Code Radio网络并开始播放音乐。
Note: You can use the URL: https://coderadio-admin.freecodecamp.org/radio/8010/radio.mp3 in any media player that supports streaming via Network. I tried to play on Quick Time player and it works!
注意:您可以在支持通过网络流式传输的任何媒体播放器中使用URL: https : //coderadio-admin.freecodecamp.org/radio/8010/radio.mp3 。 我尝试在Quick Time播放器上播放,并且有效!
其他选项:通过播放列表文件播放, (Other option: Playing via playlist file,)
Code radio is powered by AzuraCast and its public player has a "Download PLS" link that will produce a PLS playlist file and it contains all the different bitrates. The playlist file can be played in VLC media player and in other players.
代码广播由AzuraCast驱动,其公共播放器具有“下载PLS”链接,该链接将生成PLS播放列表文件,并且包含所有不同的比特率。 播放列表文件可以在VLC媒体播放器和其他播放器中播放。
You can open the playlist file - https://coderadio-admin.freecodecamp.org/public/coderadio/playlist/pls in VLC media player and choose the bitrate and start playing the music.
您可以打开播放列表文件- https://coderadio-admin.freecodecamp.org/public/coderadio/playlist/pls在VLC媒体播放器,并选择比特率,并开始播放音乐。
Enjoy listening to Code Radio music.
欣赏Code Radio音乐。
Credits: I thank Quincy Larson, Buster Neece and Louis Tsai for reviewing this article.
鸣谢:感谢Quincy Larson , Buster Neece和Louis Tsai审阅本文。
翻译自: https://www.freecodecamp.org/news/play-code-radio-on-vlc/