本文整理汇总了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);
}
示例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());
}
示例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);
}
示例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