public Callback() { if (android.os.Build.VERSION.SDK_INT >= 21) { mCallbackObj = MediaControllerCompatApi21.createCallback(new StubApi21()); } else { mCallbackObj = null; } }
@Override public PlaybackInfo getPlaybackInfo() { Object volumeInfoObj = MediaControllerCompatApi21.getPlaybackInfo(mControllerObj); return volumeInfoObj != null ? new PlaybackInfo( MediaControllerCompatApi21.PlaybackInfo.getPlaybackType(volumeInfoObj), MediaControllerCompatApi21.PlaybackInfo.getLegacyAudioStream(volumeInfoObj), MediaControllerCompatApi21.PlaybackInfo.getVolumeControl(volumeInfoObj), MediaControllerCompatApi21.PlaybackInfo.getMaxVolume(volumeInfoObj), MediaControllerCompatApi21.PlaybackInfo.getCurrentVolume(volumeInfoObj)) : null; }
@Override public void sendCommand(String command, Bundle params, ResultReceiver cb) { MediaControllerCompatApi21.sendCommand(mControllerObj, command, params, cb); }
@Override public int getRatingType() { return MediaControllerCompatApi21.getRatingType(mControllerObj); }
@Override public MediaMetadataCompat getMetadata() { Object metadataObj = MediaControllerCompatApi21.getMetadata(mControllerObj); return metadataObj != null ? MediaMetadataCompat.fromMediaMetadata(metadataObj) : null; }
@Override public PlaybackStateCompat getPlaybackState() { Object stateObj = MediaControllerCompatApi21.getPlaybackState(mControllerObj); return stateObj != null ? PlaybackStateCompat.fromPlaybackState(stateObj) : null; }
@Override public TransportControls getTransportControls() { Object controlsObj = MediaControllerCompatApi21.getTransportControls(mControllerObj); return controlsObj != null ? new TransportControlsApi21(controlsObj) : null; }
@Override public boolean dispatchMediaButtonEvent(KeyEvent event) { return MediaControllerCompatApi21.dispatchMediaButtonEvent(mControllerObj, event); }
@Override public void unregisterCallback(Callback callback) { MediaControllerCompatApi21.unregisterCallback(mControllerObj, callback.mCallbackObj); }
@Override public void registerCallback(Callback callback, Handler handler) { MediaControllerCompatApi21.registerCallback(mControllerObj, callback.mCallbackObj, handler); }
public MediaControllerImplApi21(Context context, MediaSessionCompat.Token sessionToken) throws RemoteException { // TODO: refactor framework implementation mControllerObj = MediaControllerCompatApi21.fromToken(context, sessionToken.getToken()); if (mControllerObj == null) throw new RemoteException(); }
public MediaControllerImplApi21(Context context, MediaSessionCompat session) { mControllerObj = MediaControllerCompatApi21.fromToken(context, session.getSessionToken().getToken()); }