Added documentation.
This commit is contained in:
parent
fe711adf97
commit
eff15c176e
2 changed files with 22 additions and 0 deletions
|
@ -41,6 +41,12 @@ import android.support.v7.media.MediaRouteProvider;
|
||||||
import android.support.v7.media.MediaRouter.ControlRequestCallback;
|
import android.support.v7.media.MediaRouter.ControlRequestCallback;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives control intents through media route and executes them on a MediaPlayer.
|
||||||
|
*
|
||||||
|
* @author felix
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Controller extends MediaRouteProvider.RouteController implements
|
public class Controller extends MediaRouteProvider.RouteController implements
|
||||||
MediaPlayer.OnCompletionListener, MediaPlayer.OnPreparedListener {
|
MediaPlayer.OnCompletionListener, MediaPlayer.OnPreparedListener {
|
||||||
|
|
||||||
|
@ -167,12 +173,21 @@ public class Controller extends MediaRouteProvider.RouteController implements
|
||||||
callback.onResult(status);
|
callback.onResult(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets state to finished.
|
||||||
|
*
|
||||||
|
* Note: Do not set the listener before play() is called
|
||||||
|
* (or this will be called immediately).
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCompletion(MediaPlayer mp) {
|
public void onCompletion(MediaPlayer mp) {
|
||||||
mState = MediaItemStatus.PLAYBACK_STATE_FINISHED;
|
mState = MediaItemStatus.PLAYBACK_STATE_FINISHED;
|
||||||
mPlayer.setOnCompletionListener(null);
|
mPlayer.setOnCompletionListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts playback and sets completion listener.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPrepared(MediaPlayer mp) {
|
public void onPrepared(MediaPlayer mp) {
|
||||||
mPlayer.start();
|
mPlayer.start();
|
||||||
|
|
|
@ -40,6 +40,13 @@ import android.support.v7.media.MediaRouteProvider;
|
||||||
import android.support.v7.media.MediaRouteProviderDescriptor;
|
import android.support.v7.media.MediaRouteProviderDescriptor;
|
||||||
import android.support.v7.media.MediaRouter;
|
import android.support.v7.media.MediaRouter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MediaRouteProvider that details the local audio route with its
|
||||||
|
* controls to the system.
|
||||||
|
*
|
||||||
|
* @author felix
|
||||||
|
*
|
||||||
|
*/
|
||||||
final class Provider extends MediaRouteProvider {
|
final class Provider extends MediaRouteProvider {
|
||||||
|
|
||||||
private static final String ROUTE_ID = "local_route";
|
private static final String ROUTE_ID = "local_route";
|
||||||
|
|
Reference in a new issue