Raspberry PI 3 to create a music player
1. Software Environment
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mplayer2//music playback software
sudo apt-get install Alsamixergui//volume control
2. Prepare the song
Find a song. MP3 Songs
Here is a: wget Http://blog.lxx1.com/wp-content/uploads/2016/07/shero.mp3
3, set the Raspberry Pi 3 audio output mode
sudo raspi-config
Advanced options--Audio-force 3.5mm (' headphone ') jack
If the default auto does not work, the setting is cast to 3.5mm audio output
4. Hardware Environment
If this step is skipped, you can directly plug the headphone jack into the Raspberry Pi av interface to try, it must be very sour. The noise is too loud. Hardware support is required here
noise Reason: Because the Raspberry Pi 3 AV interface is audio and video merge output, this interface is the United States standard interface, and in China is the national standard, the interface of the grounding and audio is the opposite, which leads to no use of
Solution:
I checked a lot of blogs, some said with a special Raspberry Pi play Music expansion board, some said to buy the PRC 2706 USB DAV sound card, about 50RMB, investment is not small.
Here are 2 proposals
Scenario 1, if you bought a Raspberry Pi 3 motherboard bought HDMI VGA interface line, then you are lucky, directly to the HDMI interface to the Raspberry Pi motherboard, HDMI interface powered by the Raspberry Pi motherboard USB interface, HDMI to VGA interface line also has an audio output interface, right, no mistake, Just plug in the headset and you're ready.
Scenario 2, because the Raspberry Pi 3 motherboard AV interface is the United States, need to buy a treasure on the U.S. standard to the national standard 3.5mm audio interface, also more than 10 RMB, so it can be, very convenient
5. Play Music
MPlayer *.mp3
MPlayer2 2.0-728-g2c378c7-4+b1 (C) 2000-2012 MPlayer Team
Cannot open file '/home/pi/.mplayer/input.conf ': No such file or directory
Failed to open/home/pi/.mplayer/input.conf.
Cannot open file '/etc/mplayer/input.conf ': No such file or directory
Failed to open/etc/mplayer/input.conf.
Playing *.mp3.
Detected file FORMAT:MP2/3 (MPEG Audio Layer 2/3) (Libavformat)
[mp3 @ 0x75be65b8]max_analyze_duration 5000000 reached
[LAVF] Stream 0:audio (mp3),-aid 0
Clip Info:
Encoded_by:pro Tools
Originator_reference:2ah5evtje6oaaagk
encoder:lavf55.19.100
time_reference:132439
Date:2017-07-15
Load subtitles in.
Selected Audio Codec:mpeg 1.0/2.0/2.5 layers I, II, III [mpg123]
audio:44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio:16000->176400)
AO: [Pulse] Init Failed:connection refused
AO: [Alsa] 44100Hz 2ch s16le (2 bytes per sample)
[Ao_alsa] Unable to find simple control ' Master ', 0.
Video:no Video
Starting playback ...
a:214.7 (03:34.7) of 214.8 (03:34.7) 1.5%
Alsamixer command to open the Volume control interface, keyboard up and Down Tab key control adjustment
Listen to the music, if there is a programming basis, you can prepare a music library, programmed to play the music in random or other way, the music player to play the cause of the