diff options
| author | 2015-10-14 01:27:30 +0000 | |
|---|---|---|
| committer | 2015-10-14 01:27:30 +0000 | |
| commit | acb867f17c34828d14b3c71186253a269d85707c (patch) | |
| tree | 5d63819a324e9d0dd555c4257efeaa8318015dc4 | |
| parent | f3c9215afbd3b0100a7762a91d7e4db56b902224 (diff) | |
| parent | bf76eb7cdaf1e2199217354bd6cbeaf37657486f (diff) | |
am bf76eb7c: am a2ed535c: NotificationPlayer supports MediaPlayer errors
* commit 'bf76eb7cdaf1e2199217354bd6cbeaf37657486f':
NotificationPlayer supports MediaPlayer errors
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/media/NotificationPlayer.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/media/NotificationPlayer.java b/packages/SystemUI/src/com/android/systemui/media/NotificationPlayer.java index 803a01410b9f..728d558c03b1 100644 --- a/packages/SystemUI/src/com/android/systemui/media/NotificationPlayer.java +++ b/packages/SystemUI/src/com/android/systemui/media/NotificationPlayer.java @@ -21,6 +21,7 @@ import android.media.AudioAttributes; import android.media.AudioManager; import android.media.MediaPlayer; import android.media.MediaPlayer.OnCompletionListener; +import android.media.MediaPlayer.OnErrorListener; import android.net.Uri; import android.os.Looper; import android.os.PowerManager; @@ -36,7 +37,7 @@ import java.util.LinkedList; * - whenever audio is played, audio focus is requested, * - whenever audio playback is stopped or the playback completed, audio focus is abandoned. */ -public class NotificationPlayer implements OnCompletionListener { +public class NotificationPlayer implements OnCompletionListener, OnErrorListener { private static final int PLAY = 1; private static final int STOP = 2; private static final boolean mDebug = false; @@ -112,6 +113,7 @@ public class NotificationPlayer implements OnCompletionListener { // done playing. This class should be modified to use a single thread, on which // command are issued, and on which it receives the completion callbacks. player.setOnCompletionListener(NotificationPlayer.this); + player.setOnErrorListener(NotificationPlayer.this); player.start(); if (mPlayer != null) { mPlayer.release(); @@ -245,6 +247,13 @@ public class NotificationPlayer implements OnCompletionListener { } } + public boolean onError(MediaPlayer mp, int what, int extra) { + Log.e(mTag, "error " + what + " (extra=" + extra + ") playing notification"); + // error happened, handle it just like a completion + onCompletion(mp); + return true; + } + private String mTag; private CmdThread mThread; private CreationAndCompletionThread mCompletionThread; |