[Android] Resume playback: avoid RemoteServiceException and user hint
Nicolas Pomepuy
git at videolan.org
Thu Apr 22 12:00:47 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Apr 16 09:15:46 2021 +0200| [b4a5ee316e777471dc1dcbe6d1f2293973c7830e] | committer: Nicolas Pomepuy
Resume playback: avoid RemoteServiceException and user hint
> https://code.videolan.org/videolan/vlc-android/commit/b4a5ee316e777471dc1dcbe6d1f2293973c7830e
---
application/resources/src/main/res/values/strings.xml | 1 +
application/vlc-android/src/org/videolan/vlc/PlaybackService.kt | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 2c6b40008..75935bba9 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -42,6 +42,7 @@
<string name="append_all">Append all</string>
<string name="resume_playback_short_title">Resume playback</string>
<string name="resume_playback_long_title"> Resume playback of last playlist</string>
+ <string name="resume_playback_error">Nothing to resume</string>
<string name="delete">Delete</string>
<string name="remove">Remove</string>
<string name="set_song">Set as ringtone</string>
diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index e2c4f046c..27305aaf3 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -1038,7 +1038,11 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
}
fun loadLastPlaylist(type: Int) {
- if (!playlistManager.loadLastPlaylist(type)) stopService(Intent(applicationContext, PlaybackService::class.java))
+ if (!playlistManager.loadLastPlaylist(type)) {
+ forceForeground(true)
+ Toast.makeText(this, getString(R.string.resume_playback_error), Toast.LENGTH_LONG).show()
+ stopService(Intent(applicationContext, PlaybackService::class.java))
+ }
}
fun showToast(text: String, duration: Int, isError: Boolean = false) {
More information about the Android
mailing list