即使我完成活动,mediaPlayer也不会停止
我所处的情况是,我有一个 ActivityGroup,其中有一个 Activity,我在其中使用 MediaPlayer 来播放音频文件。但是当我退出该 Activity 时,我试图停止 MediaPlayer,但不幸的是我无法做到这一点。因此,当我退出活动时,我尝试完成它。我能够完成该活动,但 MediaPlayer 仍然根本不停止。
我该怎么解决这个问题。
I am in a situation where I have an ActivityGroup and inside of which I have an Activity in which I have used MediaPlayer to play an audio file. But when I navigate out of that Activity I am trying to stop the MediaPlayer, but unfortunately I was not able to do it. So I tried finishing my activity when I navigate out of it. I am able to finish the activity but still MediaPlayer doesn't stop at all.
How should I solve this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您完成 Activity 时,
MediaPlayer
不会停止,您需要在 Activity 的onPause()
中显式调用mMediaPlayer.stop()
。MediaPlayer
won't stop when you finish your activity, you need to explicitly callmMediaPlayer.stop()
in your activity'sonPause()
.