Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ea58f1f authored by Alexander Martinz's avatar Alexander Martinz Committed by Michael Bestas
Browse files

MusicPlaybackService: catch IllegalStateException for duration and position



On some where short tracks, which eg last one second, this can crash
the service.

Change-Id: I3db9bb70bd952554b44151b457963507174208bf
Signed-off-by: Alexander Martinz's avatarAlexander Martinz <amartinz@shiftphones.com>
parent 360c9611
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -3396,7 +3396,12 @@ public class MusicPlaybackService extends Service {
         * @return The duration in milliseconds
         */
        public long duration() {
            try {
                return mCurrentMediaPlayer.getDuration();
            } catch (IllegalStateException exc) {
                Log.e(TAG, "Could not get duration", exc);
            }
            return 0L;
        }

        /**
@@ -3405,7 +3410,12 @@ public class MusicPlaybackService extends Service {
         * @return The current position in milliseconds
         */
        public long position() {
            try {
                return mCurrentMediaPlayer.getCurrentPosition();
            } catch (IllegalStateException exc) {
                Log.e(TAG, "Could not get current position", exc);
            }
            return 0L;
        }

        /**