android - 播放完歌曲后的 MediaPlayer 状态

标签 android eclipse media-player

给定图表 http://developer.android.com/reference/android/media/MediaPlayer.html#Valid_and_Invalid_States当 mediaplayer 对象正在播放然后停止播放时(因为 song finished ofc),它是进入停止状态还是仍然处于启动状态?非常感谢

最佳答案

引用您分享的链接:

When the playback reaches the end of stream, the playback completes.

If the looping mode was being set to true with setLooping(boolean), the MediaPlayer object shall remain in the Started state.

If the looping mode was set to false , the player engine calls a user supplied callback method, OnCompletion.onCompletion(), if a OnCompletionListener is registered beforehand via setOnCompletionListener(OnCompletionListener). The invoke of the callback signals that the object is now in the PlaybackCompleted state.

While in the PlaybackCompleted state, calling start() can restart the playback from the beginning of the audio/video source.

于是进入PlaybackCompletedState,播放完成后进入stop状态。如果循环设置为真,它将保持启动状态。

关于android - 播放完歌曲后的 MediaPlayer 状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22216104/

相关文章:

android - 我们如何在设备上为基于 phonegap 的 iOS 和 android 应用程序维护错误日志文件 (.txt)?

java - 修复无限循环?

循环播放声音时 Android MediaPlayer 警告

JavaFX 示例代码不播放视频,仅显示媒体播放器

android - 如何在 Android 中播放加密文件

android - 当客户端是 Android 时如何在不使用 SSL 的情况下保护 GAE 数据库

java - Android:在启动时使用XML配置文件,可能吗?

java - LibGDX AppWarp 在 Android 上得到 WarpResponseResultCode.CONNECTION_ERROR,但在桌面上工作正常?

Eclipse 显示错误,即使 maven 构建成功

java - Eclipse 插件,用于在 java 类更改后进行编译并在构建后自动部署