本文整理汇总了Java中com.google.android.exoplayer2.SimpleExoPlayer.setPlayWhenReady方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleExoPlayer.setPlayWhenReady方法的具体用法?Java SimpleExoPlayer.setPlayWhenReady怎么用?Java SimpleExoPlayer.setPlayWhenReady使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.exoplayer2.SimpleExoPlayer
的用法示例。
在下文中一共展示了SimpleExoPlayer.setPlayWhenReady方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: seekOrSkip
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private void seekOrSkip() {
if (fsmPlayer == null) {
return;
}
if (fsmPlayer instanceof FsmPlayer) {
if (((FsmPlayer) fsmPlayer).getController() != null) {
SimpleExoPlayer adPlayer = ((FsmPlayer) fsmPlayer).getController().getAdPlayer();
if (adPlayer != null && adPlayer.getPlaybackState() == ExoPlayer.STATE_BUFFERING) {
long position = adPlayer.getCurrentPosition() + 1000 < adPlayer.getDuration() ? adPlayer.getCurrentPosition() + 1000 : adPlayer.getDuration();
adPlayer.seekTo(position);
adPlayer.setPlayWhenReady(true);
return;
}
}
}
}
示例2: prepareExoPlayerForUri
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
public SimpleExoPlayer prepareExoPlayerForUri(
int playerKey,
@NonNull Context context,
@NonNull Uri uri,
@NonNull SimpleExoPlayerView simpleExoPlayerView,
int currentWindow,
boolean playWhenReady,
long playbackPosition) {
SimpleExoPlayer simpleExoPlayer = playersInUse.get(playerKey);
if (simpleExoPlayer == null) {
simpleExoPlayer = setUpMediaPlayer(context);
simpleExoPlayerView.setPlayer(simpleExoPlayer);
simpleExoPlayer.setPlayWhenReady(playWhenReady);
simpleExoPlayer.seekTo(currentWindow, playbackPosition);
MediaSource mediaSource = setUpMediaSource(context, uri);
simpleExoPlayer.prepare(mediaSource, true, false);
playersInUse.put(playerKey, simpleExoPlayer);
} else {
simpleExoPlayer.seekTo(currentWindow, playbackPosition);
simpleExoPlayer.setPlayWhenReady(playWhenReady);
}
return simpleExoPlayer;
}
示例3: stopAdandPlayerMovie
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private void stopAdandPlayerMovie(PlayerUIController controller, PlayerComponentController componentController, MediaModel movieMedia) {
SimpleExoPlayer adPlayer = controller.getAdPlayer();
SimpleExoPlayer moviePlayer = controller.getContentPlayer();
//first remove the AdPlayer's listener and pause the player
adPlayer.removeListener(componentController.getAdPlayingMonitor());
adPlayer.setPlayWhenReady(false);
//then update the playerView with SimpleExoPlayer and Movie MediaModel
TubiExoPlayerView tubiExoPlayerView = (TubiExoPlayerView) controller.getExoPlayerView();
tubiExoPlayerView.setPlayer(moviePlayer, componentController.getTubiPlaybackInterface());
tubiExoPlayerView.setMediaModel(movieMedia, false);
//prepare the moviePlayer with data source and set it play
boolean haveResumePosition = controller.getMovieResumePosition() != C.TIME_UNSET;
if (moviePlayer.getPlaybackState() == ExoPlayer.STATE_IDLE) {
moviePlayer.prepare(movieMedia.getMediaSource(), !haveResumePosition, false);
}
updatePlayerPosition(moviePlayer, controller);
moviePlayer.setPlayWhenReady(true);
hideVpaidNShowPlayer(controller);
}
示例4: onCreate
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (!isPlaying) {
Handler mainHandler = new Handler();
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector =
new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
SimpleExoPlayer player =
ExoPlayerFactory.newSimpleInstance(MainActivity.this, trackSelector, loadControl);
SimpleExoPlayerView playerView = (SimpleExoPlayerView) findViewById(R.id.videoView);
playerView.setPlayer(player);
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(MainActivity.this,
Util.getUserAgent(MainActivity.this, "yourApplicationName"));
MediaSource mediaSource = new ExtractorMediaSource(Uri.parse("https://r7---sn-3c27ln7k.googlevideo.com/videoplayback?id=6fb497d0971b8cdf&itag=22&source=picasa&begin=0&requiressl=yes&mm=30&mn=sn-3c27ln7k&ms=nxu&mv=m&nh=IgphcjAzLmticDAxKgkxMjcuMC4wLjE&pl=22&sc=yes&mime=video/mp4&lmt=1486083166327499&mt=1486135406&ip=134.249.158.189&ipbits=8&expire=1486164239&sparams=ip,ipbits,expire,id,itag,source,requiressl,mm,mn,ms,mv,nh,pl,sc,mime,lmt&signature=3BB06D8D4294F8C49B3CE910B3D6849954302BB1.02ABE00700DFCEF715E72D0EFB73B67841E659F8&key=ck2&ratebypass=yes&title=%5BAnime365%5D%20Kuzu%20no%20Honkai%20-%2004%20(t1174045)"), dataSourceFactory,
new DefaultExtractorsFactory(), null, null);
player.prepare(mediaSource);
player.setPlayWhenReady(true);
}
}
示例5: createFullPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private SimpleExoPlayer createFullPlayer() {
TrackSelection.Factory videoTrackSelectionFactory
= new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(
new DefaultRenderersFactory(playerView.getContext()),
trackSelector, loadControl);
player.setPlayWhenReady(true);
player.prepare(mediaSourceBuilder.getMediaSource(false));
player.addListener(eventListener);
return player;
}
示例6: createFullPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private SimpleExoPlayer createFullPlayer() {
TrackSelection.Factory videoTrackSelectionFactory
= new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(
new DefaultRenderersFactory(playerView.getContext()),
trackSelector, loadControl);
player.setPlayWhenReady(true);
player.prepare(mediaSourceBuilder.getMediaSource(false));
player.addListener(this);
return player;
}
示例7: createPreviewPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private SimpleExoPlayer createPreviewPlayer() {
TrackSelection.Factory videoTrackSelectionFactory = new WorstVideoTrackSelection.Factory();
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new PreviewLoadControl();
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(
new DefaultRenderersFactory(playerView.getContext()),
trackSelector, loadControl);
player.setPlayWhenReady(false);
player.setVolume(0f);
player.prepare(mediaSourceBuilder.getMediaSource(true));
return player;
}
示例8: pausePlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private static void pausePlayer(SimpleExoPlayer internalPlayer){
internalPlayer.setPlayWhenReady(false);
internalPlayer.getPlaybackState();
}
示例9: startPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private static void startPlayer(SimpleExoPlayer internalPlayer){
internalPlayer.setPlayWhenReady(true);
internalPlayer.getPlaybackState();
}
示例10: pausePlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
public static void pausePlayer(SimpleExoPlayer player) {
player.setPlayWhenReady(false);
player.getPlaybackState();
}
示例11: startPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
public static void startPlayer(SimpleExoPlayer player) {
player.setPlayWhenReady(true);
player.getPlaybackState();
}
示例12: playingAdAndPauseMovie
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
private void playingAdAndPauseMovie(PlayerUIController controller, AdMediaModel adMediaModel, PlayerComponentController componentController, FsmPlayer fsmPlayer) {
SimpleExoPlayer adPlayer = controller.getAdPlayer();
SimpleExoPlayer moviePlayer = controller.getContentPlayer();
// then setup the player for ad to playe
MediaModel adMedia = adMediaModel.nextAD();
//TODO: Handle situation when ad medaia is empty, or invalid urls.
if (adMedia != null) {
if (adMedia.isVpaid()) {
fsmPlayer.transit(Input.VPAID_MANIFEST);
return;
}
hideVpaidNShowPlayer(controller);
moviePlayer.setPlayWhenReady(false);
//prepare the moviePlayer with data source and set it play
boolean haveResumePosition = controller.getAdResumePosition() != C.TIME_UNSET;
//prepare the mediaSource to AdPlayer
adPlayer.prepare(adMedia.getMediaSource() , !haveResumePosition, true);
if (haveResumePosition) {
adPlayer.seekTo(adPlayer.getCurrentWindowIndex(), controller.getAdResumePosition());
}
//update the ExoPlayerView with AdPlayer and AdMedia
TubiExoPlayerView tubiExoPlayerView = (TubiExoPlayerView) controller.getExoPlayerView();
tubiExoPlayerView.setPlayer(adPlayer, componentController.getTubiPlaybackInterface());
tubiExoPlayerView.setMediaModel(adMedia, false);
//update the numbers of ad left to give user indicator
tubiExoPlayerView.setAvailableAdLeft(adMediaModel.nubmerOfAd());
//Player the Ad.
adPlayer.setPlayWhenReady(true);
adPlayer.addListener(componentController.getAdPlayingMonitor());
adPlayer.setAudioDebugListener(componentController.getAdPlayingMonitor());
adPlayer.setVideoDebugListener(componentController.getAdPlayingMonitor());
adPlayer.setMetadataOutput(componentController.getAdPlayingMonitor());
}
}
示例13: showImagePopup
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
public void showImagePopup(Point p, final String uri) {
Activity context = MainActivity.this;
//COMPLETED solving video problem
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.image_popup_layout);
dialog.show();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.copyFrom(dialog.getWindow().getAttributes());
dialog.getWindow().setAttributes(lp);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.getWindow().setDimAmount(0);
// Getting a reference to Close button, and close the popup when clicked.
FloatingActionButton close = (FloatingActionButton) dialog.findViewById(R.id.close_image_popup_button);
ImageView statusImage = (ImageView) dialog.findViewById(R.id.full_status_image_view);
final SimpleExoPlayerView simpleExoPlayerView = dialog.findViewById(R.id.full_status_video_view);
final SimpleExoPlayer player;
if (uri.endsWith(".jpg")) {
GlideApp.with(context).load(uri).fitCenter().into(statusImage);
} else if (uri.endsWith(".mp4")) {
statusImage.setVisibility(View.GONE);
simpleExoPlayerView.setVisibility(View.VISIBLE);
Uri myUri = Uri.parse(uri); // initialize Uri here
// 1. Create a default TrackSelector
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
// 2. Create a default LoadControl
LoadControl loadControl = new DefaultLoadControl();
// 3. Create the player
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
//Set media controller
simpleExoPlayerView.setUseController(true);
simpleExoPlayerView.requestFocus();
// Bind the player to the view.
simpleExoPlayerView.setPlayer(player);
//Measures bandwidth during playback. Can be null if not required.
DefaultBandwidthMeter bandwidthMeterA = new DefaultBandwidthMeter();
//Produces DataSource instances through which media data is loaded.
DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(this, Util.
getUserAgent(this, "exoplayer2example"), bandwidthMeterA);
//Produces Extractor instances for parsing the media data.
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource videoSource = new ExtractorMediaSource(myUri, dataSourceFactory, extractorsFactory, null, null);
player.prepare(videoSource);
player.setPlayWhenReady(true); //run file/link when ready to play.
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
player.release();
}
});
}
close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// popup.dismiss();
dialog.cancel();
}
});
}
示例14: doActionImpl
import com.google.android.exoplayer2.SimpleExoPlayer; //导入方法依赖的package包/类
@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
player.setPlayWhenReady(playWhenReady);
}