Added documentation.

This commit is contained in:
Felix Ableitner 2014-05-02 00:06:32 +02:00
parent fe711adf97
commit eff15c176e
2 changed files with 22 additions and 0 deletions

View file

@ -41,6 +41,12 @@ import android.support.v7.media.MediaRouteProvider;
import android.support.v7.media.MediaRouter.ControlRequestCallback;
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
MediaPlayer.OnCompletionListener, MediaPlayer.OnPreparedListener {
@ -167,12 +173,21 @@ public class Controller extends MediaRouteProvider.RouteController implements
callback.onResult(status);
}
/**
* Sets state to finished.
*
* Note: Do not set the listener before play() is called
* (or this will be called immediately).
*/
@Override
public void onCompletion(MediaPlayer mp) {
mState = MediaItemStatus.PLAYBACK_STATE_FINISHED;
mPlayer.setOnCompletionListener(null);
}
/**
* Starts playback and sets completion listener.
*/
@Override
public void onPrepared(MediaPlayer mp) {
mPlayer.start();

View file

@ -40,6 +40,13 @@ import android.support.v7.media.MediaRouteProvider;
import android.support.v7.media.MediaRouteProviderDescriptor;
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 {
private static final String ROUTE_ID = "local_route";