本文整理汇总了Java中android.support.v4.media.session.MediaControllerCompat.setMediaController方法的典型用法代码示例。如果您正苦于以下问题:Java MediaControllerCompat.setMediaController方法的具体用法?Java MediaControllerCompat.setMediaController怎么用?Java MediaControllerCompat.setMediaController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.media.session.MediaControllerCompat
的用法示例。
在下文中一共展示了MediaControllerCompat.setMediaController方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeMediaSession
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
private void initializeMediaSession() {
mSession = new MediaSessionCompat(this, TAG);
mSession.setFlags(
MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS
| MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
mSession.setActive(true);
MediaControllerCompat.setMediaController(this, mSession.getController());
MediaMetadataCompat metadata = new MediaMetadataCompat.Builder()
.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, mMovieView.getTitle())
.build();
mSession.setMetadata(metadata);
MediaSessionCallback mMediaSessionCallback = new MediaSessionCallback(mMovieView);
mSession.setCallback(mMediaSessionCallback);
int state =
mMovieView.isPlaying()
? PlaybackStateCompat.STATE_PLAYING
: PlaybackStateCompat.STATE_PAUSED;
updatePlaybackState(
state,
MEDIA_ACTIONS_ALL,
mMovieView.getCurrentPosition(),
mMovieView.getVideoResourceId());
}
示例2: onConnected
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onConnected() {
mMediaBrowser.subscribe(mMediaBrowser.getRoot(), mSubscriptionCallback);
try {
MediaControllerCompat mediaController =
new MediaControllerCompat(
MusicPlayerActivity.this, mMediaBrowser.getSessionToken());
updatePlaybackState(mediaController.getPlaybackState());
updateMetadata(mediaController.getMetadata());
mediaController.registerCallback(mMediaControllerCallback);
MediaControllerCompat.setMediaController(
MusicPlayerActivity.this, mediaController);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
}
示例3: connectToSession
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
private void connectToSession(MediaSessionCompat.Token token) throws RemoteException
{
LogHelper.e(TAG, "connectToSession");
MediaControllerCompat mediaController = new MediaControllerCompat(this, token);
MediaControllerCompat.setMediaController(this, mediaController);
mediaController.registerCallback(mMediaControllerCallback);
if (shouldShowControls()) {
showPlaybackControls();
} else {
LogHelper.e(TAG, "connectionCallback.onConnected: hiding controls because metadata is null");
hidePlaybackControls();
}
if (mControlsFragment != null) {
mControlsFragment.onConnected();
}
onMediaControllerConnected();
}
示例4: onMediaBrowserConnected
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onMediaBrowserConnected(StraasMediaCore client) {
mIsBind = true;
if (mFragmentActivity == null) {
Log.e(TAG, "It's not FragmentActivity.");
return;
}
MediaControllerCompat.setMediaController(mFragmentActivity, client.getMediaController());
for (ConnectionCallback connectionCallback : mMediaConnectedListenerList) {
connectionCallback.onConnected();
}
mMediaControllerCallback.onExtrasChanged(getMediaControllerCompat().getExtras());
mMediaControllerCallback.onMetadataChanged(getMediaControllerCompat().getMetadata());
mMediaControllerCallback.onPlaybackStateChanged(getMediaControllerCompat().getPlaybackState());
mMediaControllerCallback.onQueueChanged(getMediaControllerCompat().getQueue());
mMediaControllerCallback.onQueueTitleChanged(getMediaControllerCompat().getQueueTitle());
getMediaControllerCompat().registerCallback(mMediaControllerCallback);
if (mContentSeekBar != null) {
mContentSeekBar.setMediaPlayer(new PlayerControl(mFragmentActivity, null));
}
}
示例5: onConnected
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onConnected() {
LogHelper.d(TAG, "onConnected");
try {
MediaControllerCompat mediaController = new MediaControllerCompat(
TvPlaybackActivity.this, mMediaBrowser.getSessionToken());
MediaControllerCompat.setMediaController(TvPlaybackActivity.this, mediaController);
mediaController.registerCallback(mMediaControllerCallback);
MediaMetadataCompat metadata = mediaController.getMetadata();
if (metadata != null) {
mPlaybackFragment.updateMetadata(metadata);
mPlaybackFragment.updatePlaybackState(mediaController.getPlaybackState());
}
} catch (RemoteException e) {
LogHelper.e(TAG, e, "could not connect media controller");
}
}
示例6: connectToSession
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
private void connectToSession(MediaSessionCompat.Token token) throws RemoteException {
MediaControllerCompat mediaController = new MediaControllerCompat(this, token);
MediaControllerCompat.setMediaController(this, mediaController);
mediaController.registerCallback(mMediaControllerCallback);
if (shouldShowControls()) {
showPlaybackControls();
} else {
LogHelper.d(TAG, "connectionCallback.onConnected: " +
"hiding controls because metadata is null");
hidePlaybackControls();
}
if (mControlsFragment != null) {
mControlsFragment.onConnected();
}
onMediaControllerConnected();
}
示例7: connectToSession
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
private void connectToSession(MediaSessionCompat.Token token) throws RemoteException {
MediaControllerCompat mediaController = new MediaControllerCompat(
FullScreenPlayerActivity.this, token);
if (mediaController.getMetadata() == null) {
finish();
return;
}
MediaControllerCompat.setMediaController(FullScreenPlayerActivity.this, mediaController);
mediaController.registerCallback(mCallback);
PlaybackStateCompat state = mediaController.getPlaybackState();
updatePlaybackState(state);
MediaMetadataCompat metadata = mediaController.getMetadata();
if (metadata != null) {
updateMediaDescription(metadata.getDescription());
updateDuration(metadata);
}
updateProgress();
if (state != null && (state.getState() == PlaybackStateCompat.STATE_PLAYING ||
state.getState() == PlaybackStateCompat.STATE_BUFFERING)) {
scheduleSeekbarUpdate();
}
}
示例8: onConnected
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onConnected() {
Timber.d("Connected to media service");
try {
// Get the token for the MediaSession
MediaSessionCompat.Token token = mediaBrowser.getSessionToken();
// Create a MediaControllerCompat
MediaControllerCompat mediaController =
new MediaControllerCompat(
PlayaItemViewActivity.this,
token);
// Save the controller
MediaControllerCompat.setMediaController(PlayaItemViewActivity.this, mediaController);
// Finish building the UI
setupMediaTransportControls();
} catch (RemoteException e) {
e.printStackTrace();
}
}
示例9: connectToSession
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
private void connectToSession(MediaSessionCompat.Token token) throws RemoteException {
MediaControllerCompat controller = new MediaControllerCompat(this, token);
MediaControllerCompat.setMediaController(this, controller);
controller.registerCallback(mMediaControllerCallback);
//// TODO: 2017/9/14 do this in sub class
getFragment().onConnected();
}
示例10: onConnected
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onConnected() {
super.onConnected();
MediaSessionCompat.Token token=browserCompat.getSessionToken();
try {
MediaControllerCompat mediaController =new MediaControllerCompat(getActivity(), token);
// Save the controller
mediaController.registerCallback(controllerCallback);
MediaControllerCompat.setMediaController(getActivity(), mediaController);
//inject the passed query
inject();
}catch (RemoteException ex){
ex.printStackTrace();
}
}
示例11: onCreate
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int movieId = getActivity().getIntent().getIntExtra(EXTRA_MOVIE_ID, -1);
if (movieId == -1) {
Log.w(TAG, "Invalid movieId, cannot playback.");
throw new IllegalArgumentException("Invalid movieId " + movieId);
}
mPlaylistAdapter =
MockPlaylistAdapterFactory.createMoviePlaylistAdapterWithActiveMovieId(movieId);
mSession = new MediaSessionCompat(getContext(), TAG);
mSession.setFlags(
MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS
| MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
mSession.setActive(true);
MediaControllerCompat.setMediaController((Activity) getContext(), mSession.getController());
mPlayerGlue =
new PrimaryPlaybackControlsGlue<>(
getContext(),
new MediaPlayerAdapter(getContext()),
mSession.getController());
mPlayerGlue.setHost(new VideoFragmentGlueHost(this));
mPlayerGlue.addPlayerCallback(playWhenReadyPlayerCallback);
mPlayerGlue.addPlayerCallback(playPausePlayerCallback);
mMediaSessionCallback = new MediaSessionCallback(mPlayerGlue);
mSession.setCallback(mMediaSessionCallback);
playMedia(mPlaylistAdapter.getCurrentItem());
}
示例12: unsetMediaController
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
private void unsetMediaController() {
MediaControllerCompat mediaController = MediaControllerCompat.getMediaController(this);
if (mediaController != null) {
mediaController.unregisterCallback(controllerCallback);
MediaControllerCompat.setMediaController(this, null);
}
}
示例13: onConnected
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onConnected() {
LogHelper.d(TAG, "onConnected: session token ",
mMediaBrowser.getSessionToken());
try {
MediaControllerCompat mediaController = new MediaControllerCompat(
TvVerticalGridActivity.this, mMediaBrowser.getSessionToken());
MediaControllerCompat.setMediaController(TvVerticalGridActivity.this, mediaController);
browse();
} catch (RemoteException e) {
LogHelper.e(TAG, e, "could not connect media controller");
}
}
示例14: onConnected
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onConnected() {
LogHelper.d(TAG, "onConnected: session token ",
mMediaBrowser.getSessionToken());
try {
MediaControllerCompat mediaController = new MediaControllerCompat(
TvBrowseActivity.this, mMediaBrowser.getSessionToken());
MediaControllerCompat.setMediaController(TvBrowseActivity.this, mediaController);
navigateToBrowser(mMediaId);
} catch (RemoteException e) {
LogHelper.e(TAG, e, "could not connect media controller");
}
}
示例15: onConnectionSuspended
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onConnectionSuspended() {
LogHelper.d(TAG, "onConnectionSuspended");
MediaControllerCompat controllerCompat = MediaControllerCompat.getMediaController(TvPlaybackActivity.this);
controllerCompat.unregisterCallback(mMediaControllerCallback);
MediaControllerCompat.setMediaController(TvPlaybackActivity.this, null);
}