当前位置: 首页>>代码示例>>Java>>正文


Java MediaControllerCompat.getTransportControls方法代码示例

本文整理汇总了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());
        }
    }
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:24,代码来源:TrackFragment.java

示例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();

}
 
开发者ID:mobapptuts,项目名称:media-thumbnail-viewer,代码行数:22,代码来源:VideoPlayActivity.java

示例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());
    }
}
 
开发者ID:SoumyaParida,项目名称:MyGaana-Universal,代码行数:18,代码来源:MusicPlayerActivity.java

示例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);
}
 
开发者ID:googlesamples,项目名称:android-UniversalMusicPlayer,代码行数:24,代码来源:TvVerticalGridFragment.java

示例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());
    }
}
 
开发者ID:markzhai,项目名称:LyricHere,代码行数:18,代码来源:MusicPlayerActivity.java

示例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());
    }
}
 
开发者ID:Jaysaw,项目名称:NovaMusicPlayer,代码行数:12,代码来源:MainActivity.java

示例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);
}
 
开发者ID:googlesamples,项目名称:leanback-assistant,代码行数:11,代码来源:PrimaryPlaybackControlsGlue.java

示例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();
    }
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:14,代码来源:PlaybackControllerK.java

示例9: transportControls

import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
private MediaControllerCompat.TransportControls transportControls(){
    MediaControllerCompat controllerCompat=MediaControllerCompat.getMediaController(getActivity());
    return controllerCompat.getTransportControls();
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:5,代码来源:TrackFragment.java


注:本文中的android.support.v4.media.session.MediaControllerCompat.getTransportControls方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。