本文整理匯總了Java中com.google.android.exoplayer2.SimpleExoPlayer.addListener方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleExoPlayer.addListener方法的具體用法?Java SimpleExoPlayer.addListener怎麽用?Java SimpleExoPlayer.addListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.exoplayer2.SimpleExoPlayer
的用法示例。
在下文中一共展示了SimpleExoPlayer.addListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
* Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
* {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
* assignments are overridden.
*
* @param player The {@link SimpleExoPlayer} to use.
*/
public void setPlayer(SimpleExoPlayer player) {
if (this.player == player) {
return;
}
if (this.player != null) {
this.player.setTextOutput(null);
this.player.setVideoListener(null);
this.player.removeListener(componentListener);
this.player.setVideoSurface(null);
}
this.player = player;
shutterView.setVisibility(VISIBLE);
if (player != null) {
if (surfaceView instanceof TextureView) {
player.setVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
player.setVideoSurfaceView((SurfaceView) surfaceView);
}
player.setVideoListener(componentListener);
player.addListener(componentListener);
player.setTextOutput(componentListener);
}
}
示例2: setPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
public void setPlayer(SimpleExoPlayer player) {
if (this.player == player) {
return;
}
if (this.player != null) {
this.player.removeListener(this);
}
this.player = player;
if (player != null) {
player.addListener(this);
boolean playing = player.getPlayWhenReady();
setIsPlaying(playing);
}
updateAll();
}
示例3: doActionAndScheduleNextImpl
import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
@Override
protected void doActionAndScheduleNextImpl(final SimpleExoPlayer player,
final MappingTrackSelector trackSelector, final Surface surface, final Handler handler,
final ActionNode nextAction) {
if (nextAction == null) {
return;
}
Player.EventListener listener = new Player.DefaultEventListener() {
@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
if (timeline.equals(expectedTimeline)) {
player.removeListener(this);
nextAction.schedule(player, trackSelector, surface, handler);
}
}
};
player.addListener(listener);
if (player.getCurrentTimeline().equals(expectedTimeline)) {
player.removeListener(listener);
nextAction.schedule(player, trackSelector, surface, handler);
}
}
示例4: setPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
* Set the {@link SimpleExoPlayer} to use.
* <p>
* To transition a {@link SimpleExoPlayer} from targeting one view to another, it's recommended to
* use {@link #switchTargetView(SimpleExoPlayer, SimpleExoPlayerView, SimpleExoPlayerView)} rather
* than this method. If you do wish to use this method directly, be sure to attach the player to
* the new view <em>before</em> calling {@code setPlayer(null)} to detach it from the old one.
* This ordering is significantly more efficient and may allow for more seamless transitions.
*
* @param player The {@link SimpleExoPlayer} to use.
*/
public void setPlayer(SimpleExoPlayer player) {
if (this.player == player) {
return;
}
if (this.player != null) {
this.player.removeListener(componentListener);
this.player.removeTextOutput(componentListener);
this.player.removeVideoListener(componentListener);
if (surfaceView instanceof TextureView) {
this.player.clearVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
this.player.clearVideoSurfaceView((SurfaceView) surfaceView);
}
}
this.player = player;
if (useController) {
controller.setPlayer(player);
}
if (shutterView != null) {
shutterView.setVisibility(VISIBLE);
}
if (player != null) {
if (surfaceView instanceof TextureView) {
player.setVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
player.setVideoSurfaceView((SurfaceView) surfaceView);
}
player.addVideoListener(componentListener);
player.addTextOutput(componentListener);
player.addListener(componentListener);
maybeShowController(false);
updateForCurrentTrackSelections();
} else {
hideController();
hideArtwork();
}
}
示例5: setPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
* Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
* {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
* assignments are overridden.
* <p>
* @param player The {@link SimpleExoPlayer} to use.
*/
public void setPlayer(SimpleExoPlayer player, @NonNull TubiPlaybackInterface playbackInterface) {
setPlaybackInterface(playbackInterface);
if (this.player == player) {
return;
}
if (this.player != null) {
this.player.removeListener(componentListener);
this.player.clearTextOutput(componentListener);
this.player.clearVideoListener(componentListener);
if (surfaceView instanceof TextureView) {
this.player.clearVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
this.player.clearVideoSurfaceView((SurfaceView) surfaceView);
}
}
this.player = player;
if (useController) {
controller.setPlayer(player,this, playbackInterface);
}
if (shutterView != null) {
shutterView.setVisibility(VISIBLE);
}
if (player != null) {
if (surfaceView instanceof TextureView) {
player.setVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
player.setVideoSurfaceView((SurfaceView) surfaceView);
}
player.setVideoListener(componentListener);
player.setTextOutput(componentListener);
player.addListener(componentListener);
// maybeShowController(false);
updateForCurrentTrackSelections();
} else {
hideController();
hideArtwork();
}
}
示例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(eventListener);
return player;
}
示例7: 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;
}
示例8: setPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
private void setPlayer(SimpleExoPlayer player, boolean isFromSelf) {
if (this.player == player && !isFromSelf) {
return;
}
if (this.player != null) {
this.player.removeListener(componentListener);
this.player.setVideoSurface(null);
}
this.player = player;
if (useController) {
controller.setPlayer(player);
}
if (player != null) {
if (surfaceView instanceof TextureView) {
player.setVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
player.setVideoSurfaceView((SurfaceView) surfaceView);
}
player.setVideoListener(componentListener);
player.addListener(componentListener);
player.setTextOutput(componentListener);
maybeShowController(false);
} else {
shutterView.setVisibility(VISIBLE);
controller.hide();
}
}
示例9: setPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
* Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
* {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
* assignments are overridden.
*
* @param player The {@link SimpleExoPlayer} to use.
*/
public void setPlayer(SimpleExoPlayer player) {
if (this.player == player) {
return;
}
if (this.player != null) {
this.player.setTextOutput(null);
this.player.setVideoListener(null);
this.player.removeListener(componentListener);
this.player.setVideoSurface(null);
}
this.player = player;
if (useController) {
controller.setPlayer(player);
}
if (shutterView != null) {
shutterView.setVisibility(VISIBLE);
}
if (player != null) {
if (surfaceView instanceof TextureView) {
player.setVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
player.setVideoSurfaceView((SurfaceView) surfaceView);
}
player.setVideoListener(componentListener);
player.addListener(componentListener);
player.setTextOutput(componentListener);
maybeShowController(false);
updateForCurrentTrackSelections();
} else {
hideController();
hideArtwork();
}
}
示例10: setPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
* Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
* {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
* assignments are overridden.
*
* @param player The {@link SimpleExoPlayer} to use.
*/
public void setPlayer(SimpleExoPlayer player) {
if (this.player == player) {
return;
}
if (this.player != null) {
this.player.setTextOutput(null);
this.player.setVideoListener(null);
this.player.removeListener(componentListener);
this.player.setVideoSurface(null);
}
this.player = player;
if (useController) {
controller.setPlayer(player);
}
if (player != null) {
if (surfaceView instanceof TextureView) {
player.setVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
player.setVideoSurfaceView((SurfaceView) surfaceView);
}
player.setVideoListener(componentListener);
player.addListener(componentListener);
player.setTextOutput(componentListener);
maybeShowController(false);
} else {
shutterView.setVisibility(VISIBLE);
controller.hide();
}
}
示例11: ExoPlayerGlue
import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
public ExoPlayerGlue(SimpleExoPlayer player, MappingTrackSelector trackSelector, Context context) {
super(context, new int[] {PLAYBACK_SPEED_FAST_L0, PLAYBACK_SPEED_FAST_L1, PLAYBACK_SPEED_FAST_L2, PLAYBACK_SPEED_FAST_L3, PLAYBACK_SPEED_FAST_L4});
handler = new Handler();
this.player = player;
this.trackSelector = trackSelector;
player.addListener(this);
trackSelector.addListener(this);
playbackSpeed = new PlaybackSpeedTask();
}
示例12: setPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
* Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
* {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
* assignments are overridden.
* <p>
* To transition a {@link SimpleExoPlayer} from targeting one view to another, it's recommended to
* use {@link #switchTargetView(SimpleExoPlayer, SimpleExoPlayerView, SimpleExoPlayerView)} rather
* than this method. If you do wish to use this method directly, be sure to attach the player to
* the new view <em>before</em> calling {@code setPlayer(null)} to detach it from the old one.
* This ordering is significantly more efficient and may allow for more seamless transitions.
*
* @param player The {@link SimpleExoPlayer} to use.
*/
public void setPlayer(SimpleExoPlayer player) {
if (this.player == player) {
return;
}
if (this.player != null) {
this.player.removeListener(componentListener);
this.player.clearTextOutput(componentListener);
this.player.clearVideoListener(componentListener);
if (surfaceView instanceof TextureView) {
this.player.clearVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
this.player.clearVideoSurfaceView((SurfaceView) surfaceView);
}
}
this.player = player;
if (useController) {
controller.setPlayer(player);
}
if (shutterView != null) {
shutterView.setVisibility(VISIBLE);
}
if (player != null) {
if (surfaceView instanceof TextureView) {
player.setVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
player.setVideoSurfaceView((SurfaceView) surfaceView);
}
player.setVideoListener(componentListener);
player.setTextOutput(componentListener);
player.addListener(componentListener);
maybeShowController(false);
updateForCurrentTrackSelections();
} else {
hideController();
hideArtwork();
}
}
示例13: 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());
}
}
示例14: ExoPlayerPlaybackHandler
import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
public ExoPlayerPlaybackHandler(SimpleExoPlayer exoPlayer) {
this.exoPlayer = exoPlayer;
exoPlayer.addListener(this);
this.playbackHandlerPromise = new Promise<>((MessengerOperator<PlayableFile>) this);
}
示例15: setPlayer
import com.google.android.exoplayer2.SimpleExoPlayer; //導入方法依賴的package包/類
/**
* Set the {@link SimpleExoPlayer} to use.
* <p>
* To transition a {@link SimpleExoPlayer} from targeting one view to another, it's recommended to
* use {@link #switchTargetView(SimpleExoPlayer, SimpleExoPlayerView, SimpleExoPlayerView)} rather
* than this method. If you do wish to use this method directly, be sure to attach the player to
* the new view <em>before</em> calling {@code setPlayer(null)} to detach it from the old one.
* This ordering is significantly more efficient and may allow for more seamless transitions.
*
* @param player The {@link SimpleExoPlayer} to use.
*/
public void setPlayer(SimpleExoPlayer player) {
if (this.player == player) {
return;
}
if (this.player != null) {
this.player.removeListener(componentListener);
this.player.removeTextOutput(componentListener);
this.player.removeVideoListener(componentListener);
if (surfaceView instanceof TextureView) {
this.player.clearVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
this.player.clearVideoSurfaceView((SurfaceView) surfaceView);
}
}
this.player = player;
if (useController) {
controller.setPlayer(player);
}
if (shutterView != null) {
shutterView.setVisibility(VISIBLE);
}
if (subtitleView != null) {
subtitleView.setCues(null);
}
if (player != null) {
if (surfaceView instanceof TextureView) {
player.setVideoTextureView((TextureView) surfaceView);
} else if (surfaceView instanceof SurfaceView) {
player.setVideoSurfaceView((SurfaceView) surfaceView);
}
player.addVideoListener(componentListener);
player.addTextOutput(componentListener);
player.addListener(componentListener);
maybeShowController(false);
updateForCurrentTrackSelections();
} else {
hideController();
hideArtwork();
}
}