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


Java MediaPlayerAdapter类代码示例

本文整理汇总了Java中android.support.v17.leanback.media.MediaPlayerAdapter的典型用法代码示例。如果您正苦于以下问题:Java MediaPlayerAdapter类的具体用法?Java MediaPlayerAdapter怎么用?Java MediaPlayerAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MediaPlayerAdapter类属于android.support.v17.leanback.media包,在下文中一共展示了MediaPlayerAdapter类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.support.v17.leanback.media.MediaPlayerAdapter; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mMediaPlayerGlue = new PlaybackBannerControlGlue<MediaPlayerAdapter>(getContext(),
            new int[]{1}, new MediaPlayerAdapter(getContext())) {
        @Override
        public long getSupportedActions() {
            return PlaybackBannerControlGlue.ACTION_PLAY_PAUSE
                    | PlaybackBannerControlGlue.ACTION_SKIP_TO_NEXT
                    | PlaybackBannerControlGlue.ACTION_SKIP_TO_PREVIOUS;
        }
    };
    mMediaPlayerGlue.setHost(mHost);

    Bundle args = getArguments();
    mSelectedClip = args.getParcelable(PlaybackActivity.EXTRA_CLIP);
    mProgress = args.getLong(PlaybackActivity.EXTRA_PROGRESS);

    mMediaPlayerGlue.setTitle(mSelectedClip.getTitle());
    mMediaPlayerGlue.setSubtitle(mSelectedClip.getDescription());
    mMediaPlayerGlue.getPlayerAdapter().setDataSource(Uri.parse(mSelectedClip.getVideoUrl()));
    mSession = new MediaSessionCompat(getContext(), "TvLauncherSampleApp");
    mSession.setActive(true);
    mSession.setCallback(new MediaSessionCallback());
    playWhenReady();
    updatePlaybackState();
    updateMetadata(mSelectedClip);
}
 
开发者ID:googlesamples,项目名称:leanback-homescreen-channels,代码行数:29,代码来源:VideoFragment.java

示例2: onCreate

import android.support.v17.leanback.media.MediaPlayerAdapter; //导入依赖的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());
}
 
开发者ID:googlesamples,项目名称:leanback-assistant,代码行数:35,代码来源:PlaybackFragment.java

示例3: onCreate

import android.support.v17.leanback.media.MediaPlayerAdapter; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mMediaPlayerGlue = new VideoMediaPlayerGlue(getActivity(),
            new MediaPlayerAdapter(getActivity()));
    mMediaPlayerGlue.setHost(mHost);
    AudioManager audioManager = (AudioManager) getActivity()
            .getSystemService(Context.AUDIO_SERVICE);
    if (audioManager.requestAudioFocus(mOnAudioFocusChangeListener, AudioManager.STREAM_MUSIC,
            AudioManager.AUDIOFOCUS_GAIN) != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
        Log.w(TAG, "video player cannot obtain audio focus!");
    }

    mMediaPlayerGlue.setMode(PlaybackControlsRow.RepeatAction.NONE);
    MediaMetaData intentMetaData = getActivity().getIntent().getParcelableExtra(
            VideoExampleActivity.TAG);
    if (intentMetaData != null) {
        mMediaPlayerGlue.setTitle(intentMetaData.getMediaTitle());
        mMediaPlayerGlue.setSubtitle(intentMetaData.getMediaArtistName());
        mMediaPlayerGlue.getPlayerAdapter().setDataSource(
                Uri.parse(intentMetaData.getMediaSourcePath()));
    } else {
        mMediaPlayerGlue.setTitle("Diving with Sharks");
        mMediaPlayerGlue.setSubtitle("A Googler");
        mMediaPlayerGlue.getPlayerAdapter().setDataSource(Uri.parse(URL));
    }
    PlaybackSeekDiskDataProvider.setDemoSeekProvider(mMediaPlayerGlue);
    playWhenReady(mMediaPlayerGlue);
    setBackgroundType(BG_LIGHT);
}
 
开发者ID:googlesamples,项目名称:leanback-showcase,代码行数:32,代码来源:VideoConsumptionExampleFragment.java

示例4: playMainVideoOnBackground

import android.support.v17.leanback.media.MediaPlayerAdapter; //导入依赖的package包/类
private void playMainVideoOnBackground() {
    VideoMediaPlayerGlue<MediaPlayerAdapter> playerGlue = new VideoMediaPlayerGlue(
            getActivity(), new MediaPlayerAdapter(getActivity()));

    mDetailsBackground.setupVideoPlayback(playerGlue);
    playerGlue.setTitle(data.getTitle() + " (Main Video)");
    playerGlue.setSubtitle(data.getDescription());
    playerGlue.getPlayerAdapter().setDataSource(Uri.parse(data.getVideoUrl()));
    PlaybackSeekDiskDataProvider.setDemoSeekProvider(playerGlue);

    mDetailsBackground.switchToVideo();
}
 
开发者ID:googlesamples,项目名称:leanback-showcase,代码行数:13,代码来源:DetailViewExampleWithVideoBackgroundFragment.java


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