[Android] AudioPlayer: display error when seek failure

Duncan McNamara git at videolan.org
Fri Aug 13 09:05:53 UTC 2021


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Thu Aug 12 17:02:30 2021 +0200| [b847a122add71c8c7998ec4a17b5658809ca51f5] | committer: Nicolas Pomepuy

AudioPlayer: display error when seek failure

As there is no 100% reliable way to determine is a file is seekable
except by having it fail, the seek buttons cannot be hidden for
unseekable files. Instead it will display an error when the seek fails.
Closes #2137

> https://code.videolan.org/videolan/vlc-android/commit/b847a122add71c8c7998ec4a17b5658809ca51f5
---

 .../vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt     | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
index 21dc16b04..3dd0b454a 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
@@ -432,23 +432,23 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
 
     fun onRewind10(view: View) {
         playlistModel.service ?.let { service ->
-            if (service.length <= 0 || !service.isSeekable) return
-
             var position = service.time - 10000
             if (position < 0) position = 0
             if (position > service.length) position = service.length
             service.seek(position, service.length.toDouble(), true)
+            if (service.playlistManager.player.lastPosition == 0.0f && service.time > 0)
+                UiTools.snacker(requireActivity(), getString(R.string.unseekable_stream))
         }
     }
 
     fun onForward10(view: View) {
         playlistModel.service ?.let { service ->
-            if (service.length <= 0 || !service.isSeekable) return
-
             var position = service.time + 10000
             if (position < 0) position = 0
             if (position > service.length) position = service.length
             service.seek(position, service.length.toDouble(), true)
+            if (service.playlistManager.player.lastPosition == 0.0f)
+                UiTools.snacker(requireActivity(), getString(R.string.unseekable_stream))
         }
     }
 



More information about the Android mailing list