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


Java MediaControllerCompat.TransportControls方法代码示例

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

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

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

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

示例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());
    }
}
 
开发者ID:berwyn,项目名称:ponyville-live-android,代码行数:19,代码来源:FullScreenPlayerActivity.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: 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();
}
 
开发者ID:nazmulidris,项目名称:mediasession-mediaplayer,代码行数:8,代码来源:MediaBrowserAdapter.java

示例8: 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

示例9: getControls

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

示例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;
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:5,代码来源:DefaultCallback.java

示例11: onPause

import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public boolean onPause(MediaPlayerController controller, MediaControllerCompat.TransportControls controls) {
    return false;
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:5,代码来源:DefaultCallback.java

示例12: onSkipNext

import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public boolean onSkipNext(MediaPlayerController controller, MediaControllerCompat.TransportControls controls) {
    return false;
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:5,代码来源:DefaultCallback.java

示例13: onSkipPrevious

import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public boolean onSkipPrevious(MediaPlayerController controller, MediaControllerCompat.TransportControls controls) {
    return false;
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:5,代码来源:DefaultCallback.java

示例14: onFastForward

import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public boolean onFastForward(MediaPlayerController controller, MediaControllerCompat.TransportControls controls) {
    return false;
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:5,代码来源:DefaultCallback.java

示例15: onRewind

import android.support.v4.media.session.MediaControllerCompat; //导入方法依赖的package包/类
@Override
public boolean onRewind(MediaPlayerController controller, MediaControllerCompat.TransportControls controls) {
    return false;
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:5,代码来源:DefaultCallback.java


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