本文整理汇总了Java中android.support.v4.media.session.MediaControllerCompat.TransportControls方法的典型用法代码示例。如果您正苦于以下问题:Java MediaControllerCompat.TransportControls方法的具体用法?Java MediaControllerCompat.TransportControls怎么用?Java MediaControllerCompat.TransportControls使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.media.session.MediaControllerCompat
的用法示例。
在下文中一共展示了MediaControllerCompat.TransportControls方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
}
示例3: 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);
}
示例4: 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());
}
}
示例5: playPausePressed
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@OnClick(R.id.play_pause)
public void playPausePressed(View v) {
PlaybackStateCompat state = getMediaControllerCompat().getPlaybackState();
MediaControllerCompat.TransportControls controls =
getMediaControllerCompat().getTransportControls();
switch (state.getState()) {
case PlaybackStateCompat.STATE_PLAYING:
case PlaybackStateCompat.STATE_BUFFERING:
controls.stop();
break;
case PlaybackStateCompat.STATE_PAUSED:
case PlaybackStateCompat.STATE_STOPPED:
controls.play();
break;
default:
Timber.d(TAG, "onClick with state ", state.getState());
}
}
示例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: getTransportControls
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
public MediaControllerCompat.TransportControls getTransportControls() {
if (mMediaController == null) {
Log.d(TAG, "getTransportControls: MediaController is null!");
throw new IllegalStateException();
}
return mMediaController.getTransportControls();
}
示例8: transportControls
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
private MediaControllerCompat.TransportControls transportControls(){
MediaControllerCompat controllerCompat=MediaControllerCompat.getMediaController(getActivity());
return controllerCompat.getTransportControls();
}
示例9: getControls
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
private MediaControllerCompat.TransportControls getControls(){
return MediaControllerCompat.getMediaController(getActivity()).getTransportControls();
}
示例10: onPlay
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public boolean onPlay(String currentMediaId, String id, MediaPlayerController controller, MediaControllerCompat.TransportControls controls) {
return false;
}
示例11: onPause
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public boolean onPause(MediaPlayerController controller, MediaControllerCompat.TransportControls controls) {
return false;
}
示例12: onSkipNext
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public boolean onSkipNext(MediaPlayerController controller, MediaControllerCompat.TransportControls controls) {
return false;
}
示例13: onSkipPrevious
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public boolean onSkipPrevious(MediaPlayerController controller, MediaControllerCompat.TransportControls controls) {
return false;
}
示例14: onFastForward
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public boolean onFastForward(MediaPlayerController controller, MediaControllerCompat.TransportControls controls) {
return false;
}
示例15: onRewind
import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public boolean onRewind(MediaPlayerController controller, MediaControllerCompat.TransportControls controls) {
return false;
}