Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-Eleven: 提交

packages/apps/Eleven


Commit MetaInfo

修订版e34f9a60ce4bf4d8e4d1c0e1aeb0fa3a7ba4d52f (tree)
时间2019-03-20 03:42:08
作者Alexander Martinz <amartinz@shif...>
CommiterAlexander Martinz

Log Message

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 <amartinz@shiftphones.com>

更改概述

差异

--- a/src/org/lineageos/eleven/MusicPlaybackService.java
+++ b/src/org/lineageos/eleven/MusicPlaybackService.java
@@ -3396,7 +3396,12 @@ public class MusicPlaybackService extends Service {
33963396 * @return The duration in milliseconds
33973397 */
33983398 public long duration() {
3399- return mCurrentMediaPlayer.getDuration();
3399+ try {
3400+ return mCurrentMediaPlayer.getDuration();
3401+ } catch (IllegalStateException exc) {
3402+ Log.e(TAG, "Could not get duration", exc);
3403+ }
3404+ return 0L;
34003405 }
34013406
34023407 /**
@@ -3405,7 +3410,12 @@ public class MusicPlaybackService extends Service {
34053410 * @return The current position in milliseconds
34063411 */
34073412 public long position() {
3408- return mCurrentMediaPlayer.getCurrentPosition();
3413+ try {
3414+ return mCurrentMediaPlayer.getCurrentPosition();
3415+ } catch (IllegalStateException exc) {
3416+ Log.e(TAG, "Could not get current position", exc);
3417+ }
3418+ return 0L;
34093419 }
34103420
34113421 /**
Show on old repository browser