Example usage for android.media.browse MediaBrowser subscribe

List of usage examples for android.media.browse MediaBrowser subscribe

Introduction

In this page you can find the example usage for android.media.browse MediaBrowser subscribe.

Prototype

public void subscribe(@NonNull String parentId, @NonNull SubscriptionCallback callback) 

Source Link

Document

Queries for information about the media items that are contained within the specified id and subscribes to receive updates when they change.

Usage

From source file:com.orangesoft.jook.ui.tv.TvVerticalGridFragment.java

protected void setMediaId(String mediaId) {
    Log.d(TAG, "setMediaId: " + mediaId);
    if (TextUtils.equals(this.mediaId, mediaId))
        return;/*from w  w  w . j  a  v a2s.  c om*/
    MediaBrowser mediaBrowser = mediaFragmentListener.getMediaBrowser();

    if (this.mediaId != null)
        mediaBrowser.unsubscribe(mediaId);
    if (null == mediaId)
        mediaId = mediaBrowser.getRoot();
    this.mediaId = mediaId;
    mediaBrowser.subscribe(this.mediaId, subscriptionCallback);
}

From source file:com.example.android.spotifystreamer.ui.tv.TvVerticalGridFragment.java

protected void setMediaId(String mediaId) {
    LogHelper.d(TAG, "setMediaId: ", mediaId);
    if (TextUtils.equals(mMediaId, mediaId)) {
        return;/*  w w  w . j  a  v  a 2s  . c  o m*/
    }
    MediaBrowser mediaBrowser = mMediaFragmentListener.getMediaBrowser();

    // First, unsubscribe from old mediaId:
    if (mMediaId != null) {
        mediaBrowser.unsubscribe(mMediaId);
    }
    if (mediaId == null) {
        mediaId = mediaBrowser.getRoot();
    }
    mMediaId = mediaId;
    mediaBrowser.subscribe(mMediaId, mSubscriptionCallback);
}