禁用视频中的声音
您好,我是 Android 开发新手,正在开发游戏。我目前有一个打开的过场动画,它是视频视图,但如果用户从首选项菜单中选择静音音乐,我想静音。问题是我不知道如何在不完全关闭视频的情况下将视频视图中的音乐静音!
Hi I'm new to android development and working on a game. I currently have an opening cutsceen which is a videoview, but I want to mute the the sound, if the user selects mute music from the preference menu. The problem is I don't know how to mute the music in a videoview without actually turning off the video entirely!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AudioManager 并不总是一个好的选择,因为你将所有系统静音...
如果你想访问 VideoView 的 MediaPlayer,你必须调用 MediaPlayer.OnPreparedListener 和 MediaPlayer.OnCompletionListener,然后你可以调用 setVolume(0f, 0f);函数将音量设置为 0。
执行以下操作:
The AudioManager is not a good option always, because you mute all the system...
if you want to get access to the MediaPlayer of a VideoView you have to call MediaPlayer.OnPreparedListener and MediaPlayer.OnCompletionListener, then you can call setVolume(0f, 0f); function to set the volume to 0.
Do this:
您能做的最好的事情就是使用 AudioManager 将音乐流静音剪切场景开始并在完成后取消静音:VideoView 不提供独立的静音控件。
The best you can do is use AudioManager to mute the music stream at the beginning of the cut scene and unmute it once it is done: VideoView does not provide independent mute controls.