Example usage for android.support.v4.media.session MediaControllerCompat registerCallback

List of usage examples for android.support.v4.media.session MediaControllerCompat registerCallback

Introduction

In this page you can find the example usage for android.support.v4.media.session MediaControllerCompat registerCallback.

Prototype

public void registerCallback(Callback callback) 

Source Link

Usage

From source file:com.appdevper.mediaplayer.activity.BaseActivity.java

private void connectToSession(MediaSessionCompat.Token token) throws RemoteException {
    MediaControllerCompat mediaController = new MediaControllerCompat(this, token);
    setSupportMediaController(mediaController);
    mediaController.registerCallback(mMediaControllerCallback);

    if (shouldShowControls()) {
        showPlaybackControls();//from w ww  . j a  v  a2s.  co  m
    } else {
        LogHelper.d(TAG, "connectionCallback.onConnected: " + "hiding controls because metadata is null");
        hidePlaybackControls();
    }

    if (mControlsFragment != null) {
        mControlsFragment.onConnected();
    }

    onMediaControllerConnected();
}

From source file:com.scooter1556.sms.android.activity.BaseActivity.java

private void connectToSession(MediaSessionCompat.Token token) throws RemoteException {
    MediaControllerCompat mediaController = new MediaControllerCompat(this, token);
    MediaControllerCompat.setMediaController(this, mediaController);
    mediaController.registerCallback(mediaControllerCallback);

    if (shouldShowControls()) {
        showPlaybackControls();/* w ww  . java2s  .co  m*/
    } else {
        hidePlaybackControls();
    }

    if (controlsFragment != null) {
        controlsFragment.onConnected();
    }

    onMediaControllerConnected();
}

From source file:com.murati.oszk.audiobook.ui.BaseActivity.java

private void connectToSession(MediaSessionCompat.Token token) throws RemoteException {
    MediaControllerCompat mediaController = new MediaControllerCompat(this, token);
    MediaControllerCompat.setMediaController(this, mediaController);
    mediaController.registerCallback(mMediaControllerCallback);

    if (shouldShowControls()) {
        showPlaybackControls();/*  w  ww .j av  a  2 s  .c om*/
    } else {
        LogHelper.d(TAG, "connectionCallback.onConnected: " + "hiding controls because metadata is null");
        hidePlaybackControls();
    }

    if (mControlsFragment != null) {
        mControlsFragment.onConnected();
    }

    onMediaControllerConnected();
}

From source file:com.classiqo.nativeandroid_32bitz.ui.MediaBrowserFragment.java

public void onConnected() {
    if (isDetached()) {
        return;/*from   w  w w.  jav a  2 s. c  o  m*/
    }

    mMediaId = getMediaId();

    if (mMediaId == null) {
        mMediaId = mMediaFragmentListener.getMediaBrowser().getRoot();
    }

    updateTitle();

    mMediaFragmentListener.getMediaBrowser().unsubscribe(mMediaId);

    mMediaFragmentListener.getMediaBrowser().subscribe(mMediaId, mSubscriptionCallback);

    MediaControllerCompat controller = ((FragmentActivity) getActivity()).getSupportMediaController();

    if (controller != null) {
        controller.registerCallback(mMediaControllerCallback);
    }
}

From source file:com.bayapps.android.robophish.ui.tv.TvBrowseFragment.java

public void initializeWithMediaId(String mediaId) {
    LogHelper.d(TAG, "subscribeToData");
    // fetch browsing information to fill the listview:
    mMediaBrowser = mMediaFragmentListener.getMediaBrowser();

    if (mediaId == null) {
        mediaId = mMediaBrowser.getRoot();
    }//  ww  w.ja v  a 2s .  co  m

    subscribeToMediaId(mediaId, mSubscriptionCallback);

    // Add MediaController callback so we can redraw the list when metadata changes:
    MediaControllerCompat mediaController = getActivity().getSupportMediaController();
    if (mediaController != null) {
        mediaController.registerCallback(mMediaControllerCallback);
    }
}

From source file:cat.terrones.devops.radiofx.ui.MediaBrowserFragment.java

public void onConnected() {
    if (isDetached()) {
        return;//w ww  .  j a v  a2s  .c  om
    }
    mMediaId = getMediaId();
    if (mMediaId == null) {
        mMediaId = mMediaFragmentListener.getMediaBrowser().getRoot();
    }
    updateTitle();

    // Unsubscribing before subscribing is required if this mediaId already has a subscriber
    // on this MediaBrowser instance. Subscribing to an already subscribed mediaId will replace
    // the callback, but won't trigger the initial callback.onChildrenLoaded.
    //
    // This is temporary: A bug is being fixed that will make subscribe
    // consistently call onChildrenLoaded initially, no matter if it is replacing an existing
    // subscriber or not. Currently this only happens if the mediaID has no previous
    // subscriber or if the media content changes on the service side, so we need to
    // unsubscribe first.
    mMediaFragmentListener.getMediaBrowser().unsubscribe(mMediaId);

    mMediaFragmentListener.getMediaBrowser().subscribe(mMediaId, mSubscriptionCallback);

    // Add MediaController callback so we can redraw the list when metadata changes:
    MediaControllerCompat controller = ((FragmentActivity) getActivity()).getSupportMediaController();
    if (controller != null) {
        controller.registerCallback(mMediaControllerCallback);
    }
}

From source file:com.murati.oszk.audiobook.ui.tv.TvBrowseFragment.java

public void initializeWithMediaId(String mediaId) {
    LogHelper.d(TAG, "subscribeToData");
    // fetch browsing information to fill the listview:
    mMediaBrowser = mMediaFragmentListener.getMediaBrowser();

    if (mediaId == null) {
        mediaId = mMediaBrowser.getRoot();
    }//from   w w  w.j a  va  2 s.  com

    subscribeToMediaId(mediaId, mSubscriptionCallback);

    // Add MediaController callback so we can redraw the list when metadata changes:
    MediaControllerCompat mediaController = MediaControllerCompat.getMediaController(getActivity());
    if (mediaController != null) {
        mediaController.registerCallback(mMediaControllerCallback);
    }
}

From source file:com.murati.oszk.audiobook.ui.MediaBrowserFragment.java

public void onConnected() {
    if (isDetached()) {
        return;//from ww  w.  j  a  v  a 2 s  . c o m
    }
    mMediaId = getMediaId();
    if (mMediaId == null) {
        mMediaId = mMediaFragmentListener.getMediaBrowser().getRoot();
    }
    updateTitle();

    // Unsubscribing before subscribing is required if this mediaId already has a subscriber
    // on this MediaBrowser instance. Subscribing to an already subscribed mediaId will replace
    // the callback, but won't trigger the initial callback.onChildrenLoaded.
    //
    // This is temporary: A bug is being fixed that will make subscribe
    // consistently call onChildrenLoaded initially, no matter if it is replacing an existing
    // subscriber or not. Currently this only happens if the mediaID has no previous
    // subscriber or if the media content changes on the service side, so we need to
    // unsubscribe first.
    mMediaFragmentListener.getMediaBrowser().unsubscribe(mMediaId);

    mMediaFragmentListener.getMediaBrowser().subscribe(mMediaId, mSubscriptionCallback);

    // Add MediaController callback so we can redraw the list when metadata changes:
    MediaControllerCompat controller = MediaControllerCompat.getMediaController(getActivity());
    if (controller != null) {
        controller.registerCallback(mMediaControllerCallback);
    }
}

From source file:com.example.android.AudioArchive.ui.FullScreenPlayerActivity.java

private void connectToSession(MediaSessionCompat.Token token) throws RemoteException {
    MediaControllerCompat mediaController = new MediaControllerCompat(FullScreenPlayerActivity.this, token);
    if (mediaController.getMetadata() == null) {
        finish();/*from w ww  .  ja  v a 2 s . c  o  m*/
        return;
    }
    setSupportMediaController(mediaController);
    mediaController.registerCallback(mCallback);
    PlaybackStateCompat state = mediaController.getPlaybackState();
    updatePlaybackState(state);
    MediaMetadataCompat metadata = mediaController.getMetadata();
    if (metadata != null) {
        updateMediaDescription(metadata.getDescription());
        updateDuration(metadata);
    }

}

From source file:com.murati.oszk.audiobook.ui.PlaybackControlsFragment.java

public void onConnected() {
    MediaControllerCompat controller = MediaControllerCompat.getMediaController(getActivity());
    LogHelper.d(TAG, "onConnected, mediaController==null? ", controller == null);
    if (controller != null) {
        onMetadataChanged(controller.getMetadata());
        onPlaybackStateChanged(controller.getPlaybackState());
        controller.registerCallback(mCallback);
    }/* w  w w  .  jav  a 2  s.  co m*/
}