树莓派播放音乐

参考:
https://blog.csdn.net/Aguangg_6655_la/article/details/54638427?utm_source=blogxgwz4

  1. 安装MPlayer
    sudo apt-get update
    sudo apt-get install mplayer2
  2. 下载音乐到树莓派
    wget http://blog.lxx1.com/wp-content/uploads/2016/07/shero.mp3
  3. 确认配置中的音频输出参数
  4. 播放音乐
    mplayer shero.mp3
    执行这个命令的时候报错:

pi@raspberrypi:/ $ mplayer /berrycode/shero.mp3
Playing: /berrycode/shero.mp3
(+) Video --vid=1 [P] ‘e’ (mjpeg)
(+) Audio --aid=1 (mp3)
File tags:
Artist: S.H.E
Album: Shero
Title: Shero
[vo/sdl] SDL_Init failed
Error opening/initializing the selected video_out (–vo) device.
Video: no video
Exiting… (Errors when loading file)

查看mplayer命令的参数:
Usage: mpv [options] [url|path/]filename
Basic options:
–start= seek to given (percent, seconds, or hh:mm:ss) position
–no-audio do not play sound
–no-video do not play video
–fs fullscreen playback
–sub-file= specify subtitle file to use
–playlist= specify playlist file

–list-options list all mpv options
–h= print options which contain the given string in their name
发现有–no-video这样的参数,结合错误信息里有“no video”,所以尝试加上这个参数重新执行,这次播放成功了。

pi@raspberrypi:/ $ mplayer --no-video /berrycode/shero.mp3
Playing: /berrycode/shero.mp3
Video --vid=1 [P] ‘e’ (mjpeg)
(+) Audio --aid=1 (mp3)
File tags:
Artist: S.H.E
Album: Shero
Title: Shero
AO: [alsa] 44100Hz stereo 2ch s16
A: 00:00:38 / 00:03:11 (19%)

你可能感兴趣的:(树莓派学习)