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

本文介绍了解决树莓派3.5mm接口无声音问题的方法,包括配置声音输出方式,修改.asoundrc文件等内容,适用于遇到类似音频播放问题的用户。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

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

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

wget http://ny01.sycdn.kuwo.cn/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
    }

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

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值