Permalink
Browse files

pulled out my own created methods from original MediaPlayer interface…

… into a subinterface. Made a parameterized RefactoredMediaPlayer constructor to enable unit testing with mocked Looper
  • Loading branch information...
1 parent b92953b commit 126c1e9696d34845cb66600ab6528c25578502d3 @leadVisionary committed Jun 30, 2012
@@ -613,27 +613,4 @@ public abstract void setOnVideoSizeChangedListener(
* @param listener the callback that will be run
*/
public abstract void setOnInfoListener(OnInfoListener listener);
-
- public abstract void logUnhandledEvent();
-
- public abstract boolean hasNoNativeContext();
-
- public abstract void handleMediaPrepared();
-
- public abstract void handlePlaybackComplete();
-
- public abstract void handleBufferingUpdate(int arg1);
-
- public abstract void handleSeekComplete();
-
- public abstract void handleSetVideoSize(int arg1, int arg2);
-
- public abstract void handleError(int arg1, int arg2);
-
- public abstract void handleMediaInfo(int arg1, int arg2);
-
- public abstract void handleTimedText(Object object);
-
- public abstract void handleUnknown(int what);
-
}
@@ -5,7 +5,7 @@
class EventHandler extends Handler
{
- private MediaPlayer mMediaPlayer;
+ private EventedMediaPlayer mMediaPlayer;
/* Do not change these values without updating their counterparts
* in include/media/mediaplayer.h!
*/
@@ -23,7 +23,7 @@
public EventHandler(MediaPlayer mp, Looper looper) {
super(looper);
- mMediaPlayer = mp;
+ mMediaPlayer = (EventedMediaPlayer)mp;
}
@Override
@@ -0,0 +1,29 @@
+package android.media.player;
+
+import android.media.MediaPlayer;
+
+public interface EventedMediaPlayer extends MediaPlayer {
+
+ public abstract void logUnhandledEvent();
+
+ public abstract boolean hasNoNativeContext();
+
+ public abstract void handleMediaPrepared();
+
+ public abstract void handlePlaybackComplete();
+
+ public abstract void handleBufferingUpdate(int arg1);
+
+ public abstract void handleSeekComplete();
+
+ public abstract void handleSetVideoSize(int arg1, int arg2);
+
+ public abstract void handleError(int arg1, int arg2);
+
+ public abstract void handleMediaInfo(int arg1, int arg2);
+
+ public abstract void handleTimedText(Object object);
+
+ public abstract void handleUnknown(int what);
+
+}
@@ -21,7 +21,7 @@
* @see <a href="docs/GUIDE">the original user guide</a>
*
*/
-public class RefactoredMediaPlayer implements MediaPlayer
+public class RefactoredMediaPlayer implements EventedMediaPlayer
{
private final static String TAG = "MediaPlayer";
// Name of the remote interface for the media player. Must be kept
@@ -45,12 +45,15 @@
* result in an exception.</p>
*/
public RefactoredMediaPlayer() {
- setupEventHandler();
+ this(Looper.myLooper());
+ }
+
+ public RefactoredMediaPlayer(Looper looper){
+ setupEventHandler(looper);
}
- private void setupEventHandler() {
- Looper looper;
- if ((looper = Looper.myLooper()) != null) {
+ private void setupEventHandler(Looper looper) {
+ if (looper != null) {
mEventHandler = new EventHandler(this, looper);
} else if ((looper = Looper.getMainLooper()) != null) {
mEventHandler = new EventHandler(this, looper);

0 comments on commit 126c1e9

Please sign in to comment.