树莓派播放音频时3.5mm接口没有声音怎么办?

编程入门 行业动态 更新时间:2024-10-21 16:08:04

树莓派有两种声音输出方式,一种是通过HDMI口外接有输出设备的显示器输出,另一种是通过3.5mm接口连接耳机或者音箱输出。
网上一查发现不少人会遇到树莓派播放音频时3.5mm接口没有声音的情况,建议先确定是不是音量过低的问题,如果不是再看这篇文章。

在命令模式下输入sudo raspi-config



选择3.5mm声音输出方式,一般到这基本没有问题了。我们来试一下。
下载歌曲:

wget http://ny01.sycdn.kuwo/10e45e36324bd22c4ee3f042971ec973/5e369b58/resource/n2/88/20/3121399053.mp3

播放歌曲:

mplayer 3121399053.mp3

如果正常播放则出现下面这种情况:

播放不了音频如果出现:

MPlayer 1.3.0 (Debian), built with gcc-6.2.1 (C) 2000-2016 MPlayer Team
do_connect: could not connect to socket
connect: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing shero.mp3.
libavformat version 57.56.101 (external)
Mismatching header version 57.56.100
Audio only file format detected.
Load subtitles in ./
==========================================================================
Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
==========================================================================
AO: [pulse] Init failed: Connection refused
Failed to initialize audio driver 'pulse'
[AO_ALSA] alsa-lib: conf.c:1891:(_snd_config_load_with_include) :17:1:Unexpected }
[AO_ALSA] alsa-lib: conf.c:3650:(config_file_open) /home/pi/.asoundrc may be old or corrupted: consider to remove or fix it
[AO_ALSA] alsa-lib: conf.c:3572:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument
[AO_ALSA] alsa-lib: conf.c:4026:(snd_config_update_r) hooks failed, removing configuration
[AO_ALSA] Playback open error: Invalid argument
Failed to initialize audio driver 'alsa'
[AO SDL] Samplerate: 44100Hz Channels: Stereo Format s16le
[AO SDL] using aalib audio driver.
[AO SDL] Unable to open audio: No available audio device
Failed to initialize audio driver 'sdl:aalib'
Could not open/initialize audio device -> no sound.
Audio: no sound
Video: no video
			

或者输入命令arecord -l出现

ALSA lib conf.c:1891:(_snd_config_load_with_include) :17:1:Unexpected }
ALSA lib conf.c:3650:(config_file_open) /home/pi/.asoundrc may be old or corrupted: consider to remove or fix it
ALSA lib conf.c:3572:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument
ALSA lib conf.c:4026:(snd_config_update_r) hooks failed, removing configuration
arecord: device_list:281: control open (0): Invalid argument

总结以上信息好像是:/home/pi/.asoundrc可能很旧或已损坏:请考虑删除或修复它
打开文件 /home/pi/.asoundrc

sudo nano /home/pi/.asoundrc

全部替换成以下内容

    pcm.!default {
            type asym
                playback.pcm {
                    type plug
                    slave.pcm "hw:0,0"
                }
                capture.pcm {
                    type plug
                    slave.pcm "hw:1,0"
                }
    }
    ctl.!default {
           type hw
            card 2
    }

解决,再次播放应该没问题了。

更多推荐

树莓派播放音频时3.5mm接口没有声音怎么办?

本文发布于:2023-06-13 07:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1359197.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:接口   音频   声音   树莓派   mm

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!