英文:
How to make `just_audio` not interrupt the playback of whatever audio is playing in the background in Flutter?
问题
我正在使用just audio package在我的Flutter应用中播放1秒钟的蜂鸣声,主要面向iOS。
我遇到的问题是,当播放这个蜂鸣声时,其他音频(音乐、有声读物等)会停止播放,而且停止后不会自动恢复。
是否有一种方法可以在蜂鸣声播放1秒钟时,只将背景音乐的声音降低50%,然后恢复正常播放?
英文:
I'm using just audio package to play 1-second beeping sounds in my Flutter app which is aimed mainly at iOS.
The problem I'm having is that other audio (music, audiobooks, etc) is stopped whenever this beep sound gets played and it stays stopped, i.e. it doesn't resume automatically after the beep.
Is there a way to just reduce the sound of the background audio by, say 50% for that 1 second the beep is going to take and then resume the normal playback?
答案1
得分: 1
你可以使用以下包: just_audio 0.9.32 和 audio_session 0.1.13
just_audio 是一个音频播放器,而 audio_session 用于控制音频设置,即在播放哔哔声时以及哔哔声播放完成后,audio_session 会恢复先前的音频设置。
你可以使用 "setCategoryVolumeGain" 方法将音量降低50%,在哔哔声播放后,先前的音频会自动恢复。
英文:
You can use the packages : just_audio 0.9.32 and audio_session 0.1.13
just_audio is an audio player and audio_session would be used to control the audio settings i.e when the beep sound is played and as it finished the audio_session would restore the previous audio after the beep sound finishes.
You can use the "setCategoryVolumeGain" method to reduce the volume by 50% and when the beep is played after it , it would play and the previous audio would automaticall restore after the beep.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论