MPlayer是一套免費的Open Source的播放程式(http://mplayerhq.hu/design7/news.html),那就開始吧!
sudo apt-get update
sudo apt-get –y install mplayer
mplayer /home/pi/Music/Top chat replay.mp3(提醒:mp3音樂檔案不能有空格不然找不到)
使用Python播放Mplayer音樂檔案
sudo pip3 install bottle
from bottle import route, run, template
import os
def playradio(url):
action = "killall mplayer"
os.system(action)
action = "mplayer " + url + " > /dev/null &"
os.system(action)
@route('/1')
def radio1():
url = "http://live.leanstream.co/ICRTFM-MP3?args=tunein_mp3"
playradio(url)
return template('music.html')
@route('/2')
def radio2():
url = "http://stream.superfm99-1.com.tw:8555/"
playradio(url)
return template('music.html')
@route('/3')
def radio3():
url = "http://asiafm.rastream.com/asiafm-fly"
playradio(url)
return template('music.html')
@route('/stop')
def stop():
action = "killall mplayer"
os.system(action)
return template('music.html')
@route('/')
def index():
return template('music.html')
run(host='0.0.0.0', port=8080)
結語:很快就大功告成囉!樹莓派的網路收音機就完成啦!