Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Android 中是否可以在播放器时间记住它停止的位置?我需要在播放器中播放 mp3,当用户停止或应用程序暂停时,我需要记住当前状态,以便用户可以在再次启动该文件的同一时间再次播放。如何做到这一点?
当您希望保存头寸时调用 (例如getCurrentPosition(),)。将其写入持久存储(数据库、. 或其他类型的文件)。用于稍后根据需要返回该位置。MediaPlayeronPause()SharedPreferencesseekTo()
getCurrentPosition()
MediaPlayer
onPause()
SharedPreferences
seekTo()