本文整理汇总了Java中android.support.v4.media.session.MediaControllerCompat.getTransportControls方法的典型用法代码示例。如果您正苦于以下问题:Java MediaControllerCompat.getTransportControls方法的具体用法?Java MediaControllerCompat.getTransportControls怎么用?Java MediaControllerCompat.getTransportControls使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.media.session.MediaControllerCompat
的用法示例。
在下文中一共展示了MediaControllerCompat.getTransportControls方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playPause
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@OnClick(R.id.play_pause)
public void playPause(){
lastState=null;
MediaControllerCompat controllerCompat=MediaControllerCompat.getMediaController(getActivity());
PlaybackStateCompat stateCompat=controllerCompat.getPlaybackState();
if(stateCompat!=null){
MediaControllerCompat.TransportControls controls=
controllerCompat.getTransportControls();
switch (stateCompat.getState()){
case PlaybackStateCompat.STATE_PLAYING:
case PlaybackStateCompat.STATE_BUFFERING:
controls.pause();
break;
case PlaybackStateCompat.STATE_NONE:
case PlaybackStateCompat.STATE_PAUSED:
case PlaybackStateCompat.STATE_STOPPED:
controls.play();
break;
default:
Log.d(TAG, "State "+stateCompat.getState());
}
}
}
示例2: onCreate
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_play);
mPlayPauseButton = (ImageButton) findViewById(R.id.videoPlayPauseButton);
mSurfaceView = (SurfaceView) findViewById(R.id.videoSurfaceView);
Intent callingIntent = this.getIntent();
if(callingIntent != null) {
mVideoUri = callingIntent.getData();
}
mSession = new MediaSessionCompat(this, TAG);
mSession.setCallback(new MediaSessionCallback(this));
mSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
mPBuilder = new PlaybackStateCompat.Builder();
mController = new MediaControllerCompat(this, mSession);
mControllerTransportControls = mController.getTransportControls();
}
示例3: onMediaItemSelected
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onMediaItemSelected(MediaBrowserCompat.MediaItem item) {
LogHelper.d(TAG, "onMediaItemSelected, mediaId=" + item.getMediaId());
if (item.isPlayable()) {
final MediaControllerCompat mediaController = getSupportMediaController();
if (mediaController != null) {
MediaSessionCompat.Token token = mediaController.getSessionToken();
MediaControllerCompat.TransportControls tc = mediaController.getTransportControls();
mediaController.getTransportControls().playFromMediaId(item.getMediaId(), null);
}
} else if (item.isBrowsable()) {
navigateToBrowser(item.getMediaId());
} else {
LogHelper.w(TAG, "Ignoring MediaItem that is neither browsable nor playable: ",
"mediaId=", item.getMediaId());
}
}
示例4: onItemClicked
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
MediaControllerCompat controller = MediaControllerCompat.getMediaController(getActivity());
if (controller == null) {
return;
}
MediaControllerCompat.TransportControls controls = controller.getTransportControls();
MediaBrowserCompat.MediaItem mediaItem = (MediaBrowserCompat.MediaItem) item;
if (!MediaIDHelper.isMediaItemPlaying(getActivity(), mediaItem)) {
controls.playFromMediaId(mediaItem.getMediaId(), null);
}
Intent intent = new Intent(getActivity(), TvPlaybackActivity.class);
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
getActivity(),
((ImageCardView) itemViewHolder.view).getMainImageView(),
TvVerticalGridActivity.SHARED_ELEMENT_NAME).toBundle();
getActivity().startActivity(intent, bundle);
}
示例5: onMediaItemSelected
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onMediaItemSelected(MediaBrowserCompat.MediaItem item) {
LogUtils.d(TAG, "onMediaItemSelected, mediaId=" + item.getMediaId());
if (item.isPlayable()) {
final MediaControllerCompat mediaController = getSupportMediaController();
if (mediaController != null) {
MediaSessionCompat.Token token = mediaController.getSessionToken();
MediaControllerCompat.TransportControls tc = mediaController.getTransportControls();
mediaController.getTransportControls().playFromMediaId(item.getMediaId(), null);
}
} else if (item.isBrowsable()) {
navigateToBrowser(item.getMediaId());
} else {
LogUtils.w(TAG, "Ignoring MediaItem that is neither browsable nor playable: ",
"mediaId=", item.getMediaId());
}
}
示例6: onMediaItemSelected
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onMediaItemSelected(MediaBrowserCompat.MediaItem item) {
if (item.isPlayable()) {
MediaControllerCompat controller = MediaControllerCompat.getMediaController(this);
MediaControllerCompat.TransportControls controls = controller.getTransportControls();
controls.playFromMediaId(item.getMediaId(), null);
} else if (item.isBrowsable()) {
summitFragment(item.getMediaId());
}
}
示例7: PrimaryPlaybackControlsGlue
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
public PrimaryPlaybackControlsGlue(
Context context, T adapter, MediaControllerCompat mediaController) {
super(context, adapter);
mMediaSessionTransportControls = mediaController.getTransportControls();
mSkipPreviousAction = new PlaybackControlsRow.SkipPreviousAction(context);
mSkipNextAction = new PlaybackControlsRow.SkipNextAction(context);
mFastForwardAction = new PlaybackControlsRow.FastForwardAction(context);
mRewindAction = new PlaybackControlsRow.RewindAction(context);
}
示例8: onConnected
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public void onConnected() {
try {
MediaControllerCompat mediaControllerCompat = new MediaControllerCompat(mAppContext, mMediaBrowser.getSessionToken());
mMediaController = new MediaControllerProxyImplK(mediaControllerCompat);
mTransportControls = new TransportControlsProxyImplK(mediaControllerCompat.getTransportControls());
mWaitingForService = false;
mController.onConnected();
} catch (RemoteException e) {
Timber.e(e, "onConnected()");
onDisconnect();
}
}
示例9: transportControls
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
private MediaControllerCompat.TransportControls transportControls(){
MediaControllerCompat controllerCompat=MediaControllerCompat.getMediaController(getActivity());
return controllerCompat.getTransportControls();
}