Search in sources :

Example 6 with MediaBrowserCompat

use of android.support.v4.media.MediaBrowserCompat in project android-UniversalMusicPlayer by googlesamples.

the class TvBrowseActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LogHelper.d(TAG, "Activity onCreate");
    setContentView(R.layout.tv_activity_player);
    mMediaBrowser = new MediaBrowserCompat(this, new ComponentName(this, MusicService.class), mConnectionCallback, null);
}
Also used : MediaBrowserCompat(android.support.v4.media.MediaBrowserCompat) ComponentName(android.content.ComponentName)

Example 7 with MediaBrowserCompat

use of android.support.v4.media.MediaBrowserCompat in project android-UniversalMusicPlayer by googlesamples.

the class TvVerticalGridActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tv_vertical_grid);
    mMediaId = getIntent().getStringExtra(TvBrowseActivity.SAVED_MEDIA_ID);
    mTitle = getIntent().getStringExtra(TvBrowseActivity.BROWSE_TITLE);
    getWindow().setBackgroundDrawableResource(R.drawable.bg);
    mMediaBrowser = new MediaBrowserCompat(this, new ComponentName(this, MusicService.class), mConnectionCallback, null);
}
Also used : MediaBrowserCompat(android.support.v4.media.MediaBrowserCompat) ComponentName(android.content.ComponentName)

Example 8 with MediaBrowserCompat

use of android.support.v4.media.MediaBrowserCompat in project android-UniversalMusicPlayer by googlesamples.

the class TvVerticalGridFragment method onStop.

@Override
public void onStop() {
    super.onStop();
    MediaBrowserCompat mediaBrowser = mMediaFragmentListener.getMediaBrowser();
    if (mediaBrowser != null && mediaBrowser.isConnected() && mMediaId != null) {
        mediaBrowser.unsubscribe(mMediaId);
    }
}
Also used : MediaBrowserCompat(android.support.v4.media.MediaBrowserCompat)

Example 9 with MediaBrowserCompat

use of android.support.v4.media.MediaBrowserCompat in project android-UniversalMusicPlayer by googlesamples.

the class TvVerticalGridFragment method setMediaId.

protected void setMediaId(String mediaId) {
    LogHelper.d(TAG, "setMediaId: ", mediaId);
    if (TextUtils.equals(mMediaId, mediaId)) {
        return;
    }
    MediaBrowserCompat 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);
}
Also used : MediaBrowserCompat(android.support.v4.media.MediaBrowserCompat)

Example 10 with MediaBrowserCompat

use of android.support.v4.media.MediaBrowserCompat in project android-UniversalMusicPlayer by googlesamples.

the class MediaBrowserFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    // fetch browsing information to fill the listview:
    MediaBrowserCompat mediaBrowser = mMediaFragmentListener.getMediaBrowser();
    LogHelper.d(TAG, "fragment.onStart, mediaId=", mMediaId, "  onConnected=" + mediaBrowser.isConnected());
    if (mediaBrowser.isConnected()) {
        onConnected();
    }
    // Registers BroadcastReceiver to track network connection changes.
    this.getActivity().registerReceiver(mConnectivityChangeReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
Also used : MediaBrowserCompat(android.support.v4.media.MediaBrowserCompat) IntentFilter(android.content.IntentFilter)

Aggregations

MediaBrowserCompat (android.support.v4.media.MediaBrowserCompat)10 ComponentName (android.content.ComponentName)5 ActivityManager (android.app.ActivityManager)1 IntentFilter (android.content.IntentFilter)1 MediaControllerCompat (android.support.v4.media.session.MediaControllerCompat)1 PlaybackStateCompat (android.support.v4.media.session.PlaybackStateCompat)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 SeekBar (android.widget.SeekBar)1 TextView (android.widget.TextView)1