Java 类com.google.android.exoplayer2.ExoPlayer 实例源码

项目:react-native-videoplayer    文件:ReactExoplayerView.java   
@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case SHOW_PROGRESS:
            if (player != null
                    && player.getPlaybackState() == ExoPlayer.STATE_READY
                    && player.getPlayWhenReady()
                    ) {
                long pos = player.getCurrentPosition();
                eventEmitter.progressChanged(pos, player.getBufferedPercentage());
                msg = obtainMessage(SHOW_PROGRESS);
                sendMessageDelayed(msg, 1000 - (pos % 1000));
            }
            break;
    }
}
项目:react-native-videoplayer    文件:ReactExoplayerView.java   
private void startPlayback() {
    if (player != null) {
        switch (player.getPlaybackState()) {
            case ExoPlayer.STATE_IDLE:
            case ExoPlayer.STATE_ENDED:
                initializePlayer();
                break;
            case ExoPlayer.STATE_BUFFERING:
            case ExoPlayer.STATE_READY:
                if (!player.getPlayWhenReady()) {
                    setPlayWhenReady(true);
                }
                break;
            default:
                break;
        }

    } else {
        initializePlayer();
    }
    if (!disableFocus) {
        setKeepScreenOn(true);
    }
}
项目:yjPlay    文件:ImaAdsLoader.java   
@Override
public void attachPlayer(ExoPlayer player, EventListener eventListener, ViewGroup adUiViewGroup) {
  this.player = player;
  this.eventListener = eventListener;
  this.adUiViewGroup = adUiViewGroup;
  lastAdProgress = null;
  lastContentProgress = null;
  adDisplayContainer.setAdContainer(adUiViewGroup);
  player.addListener(this);
  if (adPlaybackState != null) {
    eventListener.onAdPlaybackState(adPlaybackState.copy());
    if (imaPausedContent && player.getPlayWhenReady()) {
      adsManager.resume();
    }
  } else {
    requestAds();
  }
}
项目:TubiPlayer    文件:DoubleViewTubiPlayerActivity.java   
/**
 * update the movie and ad playing position when players are released
 */
@Override
protected void updateResumePosition() {
    super.updateResumePosition();

    //keep track of movie player's position when activity resume back
    if (mTubiExoPlayer != null && playerUIController != null && mTubiExoPlayer.getPlaybackState() != ExoPlayer.STATE_IDLE) {
        int resumeWindow = mTubiExoPlayer.getCurrentWindowIndex();
        long resumePosition = mTubiExoPlayer.isCurrentWindowSeekable() ? Math.max(0, mTubiExoPlayer.getCurrentPosition())
                : C.TIME_UNSET;
        playerUIController.setMovieResumeInfo(resumeWindow, resumePosition);
    }

    //keep track of ad player's position when activity resume back, only keep track when current state is in AdPlayingState.
    if (fsmPlayer.getCurrentState() instanceof AdPlayingState && adPlayer != null && playerUIController != null && adPlayer.getPlaybackState() != ExoPlayer.STATE_IDLE) {
        int ad_resumeWindow = adPlayer.getCurrentWindowIndex();
        long ad_resumePosition = adPlayer.isCurrentWindowSeekable() ? Math.max(0, adPlayer.getCurrentPosition())
                : C.TIME_UNSET;
        playerUIController.setAdResumeInfo(ad_resumeWindow, ad_resumePosition);
    }
}
项目:TubiPlayer    文件:AdPlayingMonitor.java   
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;
            }
        }
    }
}
项目:TubiPlayer    文件:FsmPlayer.java   
/**
 * update the resume position of the main movice
 *
 * @param controller
 */
public static void updateMovieResumePosition(PlayerUIController controller) {

    if (controller == null) {
        return;
    }

    SimpleExoPlayer moviePlayer = controller.getContentPlayer();

    if (moviePlayer != null && moviePlayer.getPlaybackState() != ExoPlayer.STATE_IDLE) {
        int resumeWindow = moviePlayer.getCurrentWindowIndex();
        long resumePosition = moviePlayer.isCurrentWindowSeekable() ? Math.max(0, moviePlayer.getCurrentPosition())
                : C.TIME_UNSET;
        controller.setMovieResumeInfo(resumeWindow, resumePosition);
    }
}
项目:TubiPlayer    文件:ReceiveAdState.java   
@Override
public void performWorkAndupdatePlayerUI(@Nullable FsmPlayer fsmPlayer, @NonNull PlayerUIController controller, @NonNull PlayerComponentController componentController, @NonNull MediaModel movieMedia, @Nullable AdMediaModel adMedia) {
    // doesn't need to do any UI work.

    if (isNull(fsmPlayer, controller, componentController, movieMedia, adMedia)) {
        return;
    }

    SimpleExoPlayer moviePlayer = controller.getContentPlayer();

    // this mean, user jump out of the activity lifecycle in ReceivedAdState.
    if (moviePlayer!=null && moviePlayer.getPlaybackState() == ExoPlayer.STATE_IDLE) {
        fsmPlayer.transit(Input.ERROR);
    }

}
项目:ExoPlayer-Offline    文件:ExoHostedTest.java   
@Override
public final void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
  Log.d(tag, "state [" + playWhenReady + ", " + playbackState + "]");
  playerWasPrepared |= playbackState != ExoPlayer.STATE_IDLE;
  if (playbackState == ExoPlayer.STATE_ENDED
      || (playbackState == ExoPlayer.STATE_IDLE && playerWasPrepared)) {
    playerFinished = true;
  }
  boolean playing = playWhenReady && playbackState == ExoPlayer.STATE_READY;
  if (!this.playing && playing) {
    lastPlayingStartTimeMs = SystemClock.elapsedRealtime();
  } else if (this.playing && !playing) {
    totalPlayingTimeMs += SystemClock.elapsedRealtime() - lastPlayingStartTimeMs;
  }
  this.playing = playing;
}
项目:QSVideoPlayer    文件:ExoMedia.java   
@Override
public void onPlayerStateChanged(boolean b, int i) {
    Log.e("ExoMedia", "onPlayerStateChanged " + b + i);

    if (i == ExoPlayer.STATE_READY) {
        if (!isPrepar) {
            isPrepar = true;
            iMediaCallback.onPrepared(this);//第一次初始化
        }
        //缓冲好了
        iMediaCallback.onInfo(this, MEDIA_INFO_BUFFERING_END, MEDIA_INFO_BUFFERING_END);
        mainThreadHandler.removeCallbacks(runnable);
        mainThreadHandler.post(runnable);
    }
    //播放完毕
    if (i == ExoPlayer.STATE_ENDED) {
        mainThreadHandler.removeCallbacks(runnable);
        iMediaCallback.onCompletion(this);
    }
    if (i == ExoPlayer.STATE_BUFFERING)
        iMediaCallback.onInfo(this, MEDIA_INFO_BUFFERING_START, MEDIA_INFO_BUFFERING_START);

}
项目:P2Video-master    文件:PlayerActivity.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    switch (playbackState) {

        case ExoPlayer.STATE_ENDED:
            //Log.d(TAG, "player state -> STATE_ENDED");
            mPlayer.stop();
            break;

        case ExoPlayer.STATE_IDLE:
            //Log.d(TAG, "player state -> STATE_IDLE");
            break;

        case ExoPlayer.STATE_READY:
            //Log.d(TAG, "player state -> STATE_READY");
            break;

        case ExoPlayer.STATE_BUFFERING:
           // Log.d(TAG, "player state -> STATE_BUFFERING");
            break;
        default:

            break;
    }
}
项目:tumbviewer    文件:CommonExoPlayerView.java   
@Override
public void onClick(View v) {
    if (v == playView && player != null) {
        if (player.getPlaybackState() == ExoPlayer.STATE_ENDED) {
            player.seekTo(0);
            player.setPlayWhenReady(true);
        } else {
            player.setPlayWhenReady(!player.getPlayWhenReady());
        }
    } else if (v == fullscreen) {
        Intent playerIntent = new Intent(getContext(), VideoPlayerActivity.class);
        playerIntent.putExtra("uri", uri);
        playerIntent.putExtra("position", player.getCurrentPosition());
        playerIntent.putExtra("windowIndex", player.getCurrentWindowIndex());
        playerIntent.putExtra("rotation", getWidth() > getHeight());
        getContext().startActivity(playerIntent);
        disconnect();
        playerInstance.startFullScreenMode();
    } else if (v == videoView) {
        if (isConnected) {
            show();
        } else {
            connect();
        }
    }
}
项目:MyAnimeViewer    文件:VideoDetailsFragment.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    switch (playbackState) {
        case ExoPlayer.STATE_BUFFERING:
        case ExoPlayer.STATE_READY:
            replayImageButton.setVisibility(View.GONE);
            exoButtonsFrameLayout.setVisibility(View.VISIBLE);
            break;
        case ExoPlayer.STATE_ENDED:
            exoButtonsFrameLayout.setVisibility(View.GONE);
            replayImageButton.setVisibility(View.VISIBLE);
            break;
        default:
            break;
    }
}
项目:MyAnimeViewer    文件:OfflineVideoDetailsFragment.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    switch (playbackState) {
        case ExoPlayer.STATE_BUFFERING:
        case ExoPlayer.STATE_READY:
            replayImageButton.setVisibility(View.GONE);
            exoButtonsFrameLayout.setVisibility(View.VISIBLE);
            break;
        case ExoPlayer.STATE_ENDED:
            exoButtonsFrameLayout.setVisibility(View.GONE);
            replayImageButton.setVisibility(View.VISIBLE);
            break;
        default:
            break;
    }
}
项目:MyAnimeViewer    文件:VideoPlayerActivity.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    switch (playbackState) {
        case ExoPlayer.STATE_BUFFERING:
            replayImageButton.setVisibility(View.GONE);
            exoButtonsFrameLayout.setVisibility(View.VISIBLE);
            break;
        case ExoPlayer.STATE_READY:
            replayImageButton.setVisibility(View.GONE);
            exoButtonsFrameLayout.setVisibility(View.VISIBLE);
            break;
        case ExoPlayer.STATE_ENDED:
            exoButtonsFrameLayout.setVisibility(View.GONE);
            replayImageButton.setVisibility(View.VISIBLE);
            break;
        default:
            break;
    }
}
项目:lighthouse    文件:MediaPlayerService.java   
@Override
public void run() {
    int state = mediaPlayer.getPlaybackState();
    if (state == ExoPlayer.STATE_READY) {
        long pos = mediaPlayer.getCurrentPosition();
        float speed = mediaPlayer.getPlaybackParameters().speed;

        if (!notificationManager.startNotification()) {
            notificationManager.updateNotification();
        }
        stateBuilder.setBufferedPosition(mediaPlayer.getBufferedPercentage());
        int sessionState = mediaPlayer.getPlayWhenReady() ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED;
        mediaSession.setPlaybackState(stateBuilder.setState(sessionState, pos, speed).build());
        if (mediaPlayer.getPlayWhenReady()) {
            progressHandler.postDelayed(progressRunnable, 1000 - (pos % 1000));
        }
    }
}
项目:YouTube-In-Background    文件:LocalPlayback.java   
@Override
public int getState()
{
    if (exoPlayer == null) {
        return exoPlayerNullIsStopped
                ? PlaybackStateCompat.STATE_STOPPED
                : PlaybackStateCompat.STATE_NONE;
    }
    switch (exoPlayer.getPlaybackState()) {
        case ExoPlayer.STATE_IDLE:
            return PlaybackStateCompat.STATE_PAUSED;
        case ExoPlayer.STATE_BUFFERING:
            return PlaybackStateCompat.STATE_BUFFERING;
        case ExoPlayer.STATE_READY:
            return exoPlayer.getPlayWhenReady()
                    ? PlaybackStateCompat.STATE_PLAYING
                    : PlaybackStateCompat.STATE_PAUSED;
        case ExoPlayer.STATE_ENDED:
            return PlaybackStateCompat.STATE_PAUSED;
        default:
            return PlaybackStateCompat.STATE_NONE;
    }
}
项目:YouTube-In-Background    文件:LocalPlayback.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState)
{
    switch (playbackState) {
        case ExoPlayer.STATE_IDLE:
        case ExoPlayer.STATE_BUFFERING:
        case ExoPlayer.STATE_READY:
            if (callback != null) {
                callback.onPlaybackStatusChanged(getState());
            }
            break;
        case ExoPlayer.STATE_ENDED:
            // The media player finished playing the current song.
            if (callback != null) {
                callback.onCompletion();
            }
            break;
    }
}
项目:K-Sonic    文件:DebugTextViewHelper.java   
private String getPlayerStateString() {
  String text = "playWhenReady:" + player.getPlayWhenReady() + " playbackState:";
  switch (player.getPlaybackState()) {
    case ExoPlayer.STATE_BUFFERING:
      text += "buffering";
      break;
    case ExoPlayer.STATE_ENDED:
      text += "ended";
      break;
    case ExoPlayer.STATE_IDLE:
      text += "idle";
      break;
    case ExoPlayer.STATE_READY:
      text += "ready";
      break;
    default:
      text += "unknown";
      break;
  }
  return text;
}
项目:videoPickPlayer    文件:DebugTextViewHelper.java   
private String getPlayerStateString() {
  String text = "playWhenReady:" + player.getPlayWhenReady() + " playbackState:";
  switch (player.getPlaybackState()) {
    case ExoPlayer.STATE_BUFFERING:
      text += "buffering";
      break;
    case ExoPlayer.STATE_ENDED:
      text += "ended";
      break;
    case ExoPlayer.STATE_IDLE:
      text += "idle";
      break;
    case ExoPlayer.STATE_READY:
      text += "ready";
      break;
    default:
      text += "unknown";
      break;
  }
  return text;
}
项目:leanback-showcase    文件:ExoPlayerAdapter.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    mBufferingStart = false;
    if (playbackState == ExoPlayer.STATE_READY && !mInitialized) {
        mInitialized = true;
        if (mSurfaceHolderGlueHost == null || mHasDisplay) {
            getCallback().onPreparedStateChanged(ExoPlayerAdapter.this);
        }
    } else if (playbackState == ExoPlayer.STATE_BUFFERING) {
        mBufferingStart = true;
    } else if (playbackState == ExoPlayer.STATE_ENDED) {
        getCallback().onPlayStateChanged(ExoPlayerAdapter.this);
        getCallback().onPlayCompleted(ExoPlayerAdapter.this);
    }
    notifyBufferingStartEnd();
}
项目:PainlessMusicPlayer    文件:ExoMediaPlayer.java   
@Override
public void onPlayerStateChanged(final boolean playWhenReady, final int playbackState) {
    if (Log.logDEnabled()) {
        Log.d(TAG, "onPlayerStateChanged: " + playbackState);
    }
    if (mMediaPlayerListener != null) {
        switch (playbackState) {
            case ExoPlayer.STATE_READY:
                mLoadedMediaUri = mLoadingMediaUri;
                if (playWhenReady) {
                    mMediaPlayerListener.onPlaybackStarted();
                } else {
                    mMediaPlayerListener.onPlaybackPaused();
                }
                break;

            case ExoPlayer.STATE_ENDED:
                mMediaPlayerListener.onPlaybackFinished();
                break;
        }
    }
}
项目:freesound-android    文件:ExoPlayerAudioPlayer.java   
@NonNull
private static State toState(@NonNull final ExoPlayerState exoPlayerState) {
    int exoplaybackState = exoPlayerState.getPlaybackState();
    switch (exoplaybackState) {
        case ExoPlayer.STATE_IDLE:
            return State.IDLE;
        case ExoPlayer.STATE_BUFFERING:
            return State.BUFFERING;
        case ExoPlayer.STATE_READY:
            return exoPlayerState.getPlayWhenReady() ?
                    State.PLAYING : State.PAUSED;
        case ExoPlayer.STATE_ENDED:
            return State.ENDED;
        default:
            throw new IllegalStateException("Unsupported Exoplayer state: " + exoplaybackState);
    }
}
项目:Komica    文件:VpxPlaybackTest.java   
@Override
public void run() {
  Looper.prepare();
  LibvpxVideoRenderer videoRenderer = new LibvpxVideoRenderer(true, 0);
  DefaultTrackSelector trackSelector = new DefaultTrackSelector();
  player = ExoPlayerFactory.newInstance(new Renderer[] {videoRenderer}, trackSelector);
  player.addListener(this);
  ExtractorMediaSource mediaSource = new ExtractorMediaSource(
      uri,
      new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test"),
      MatroskaExtractor.FACTORY,
      null,
      null);
  player.sendMessages(new ExoPlayer.ExoPlayerMessage(videoRenderer,
      LibvpxVideoRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
      new VpxVideoSurfaceView(context)));
  player.prepare(mediaSource);
  player.setPlayWhenReady(true);
  Looper.loop();
}
项目:android-UniversalMusicPlayer    文件:LocalPlayback.java   
@Override
public int getState() {
    if (mExoPlayer == null) {
        return mExoPlayerNullIsStopped
                ? PlaybackStateCompat.STATE_STOPPED
                : PlaybackStateCompat.STATE_NONE;
    }
    switch (mExoPlayer.getPlaybackState()) {
        case ExoPlayer.STATE_IDLE:
            return PlaybackStateCompat.STATE_PAUSED;
        case ExoPlayer.STATE_BUFFERING:
            return PlaybackStateCompat.STATE_BUFFERING;
        case ExoPlayer.STATE_READY:
            return mExoPlayer.getPlayWhenReady()
                    ? PlaybackStateCompat.STATE_PLAYING
                    : PlaybackStateCompat.STATE_PAUSED;
        case ExoPlayer.STATE_ENDED:
            return PlaybackStateCompat.STATE_PAUSED;
        default:
            return PlaybackStateCompat.STATE_NONE;
    }
}
项目:android-UniversalMusicPlayer    文件:LocalPlayback.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    switch (playbackState) {
        case ExoPlayer.STATE_IDLE:
        case ExoPlayer.STATE_BUFFERING:
        case ExoPlayer.STATE_READY:
            if (mCallback != null) {
                mCallback.onPlaybackStatusChanged(getState());
            }
            break;
        case ExoPlayer.STATE_ENDED:
            // The media player finished playing the current song.
            if (mCallback != null) {
                mCallback.onCompletion();
            }
            break;
    }
}
项目:ExoMedia    文件:ExoMediaPlayer.java   
protected void sendMessage(int renderType, int messageType, Object message, boolean blocking) {
    if (renderers.isEmpty()) {
        return;
    }

    List<ExoPlayer.ExoPlayerMessage> messages = new ArrayList<>();
    for (Renderer renderer : renderers) {
        if (renderer.getTrackType() == renderType) {
            messages.add(new ExoPlayer.ExoPlayerMessage(renderer, messageType, message));
        }
    }

    if (blocking) {
        player.blockingSendMessages(messages.toArray(new ExoPlayer.ExoPlayerMessage[messages.size()]));
    } else {
        player.sendMessages(messages.toArray(new ExoPlayer.ExoPlayerMessage[messages.size()]));
    }
}
项目:transistor    文件:VpxPlaybackTest.java   
@Override
public void run() {
  Looper.prepare();
  LibvpxVideoRenderer videoRenderer = new LibvpxVideoRenderer(true, 0);
  DefaultTrackSelector trackSelector = new DefaultTrackSelector();
  player = ExoPlayerFactory.newInstance(new Renderer[] {videoRenderer}, trackSelector);
  player.addListener(this);
  MediaSource mediaSource =
      new ExtractorMediaSource.Factory(
              new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test"))
          .setExtractorsFactory(MatroskaExtractor.FACTORY)
          .createMediaSource(uri);
  player.sendMessages(new ExoPlayer.ExoPlayerMessage(videoRenderer,
      LibvpxVideoRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
      new VpxVideoSurfaceView(context)));
  player.prepare(mediaSource);
  player.setPlayWhenReady(true);
  Looper.loop();
}
项目:transistor    文件:ImaAdsLoader.java   
@Override
public void attachPlayer(ExoPlayer player, EventListener eventListener, ViewGroup adUiViewGroup) {
  this.player = player;
  this.eventListener = eventListener;
  this.adUiViewGroup = adUiViewGroup;
  lastAdProgress = null;
  lastContentProgress = null;
  adDisplayContainer.setAdContainer(adUiViewGroup);
  player.addListener(this);
  maybeNotifyAdError();
  if (adPlaybackState != null) {
    // Pass the ad playback state to the player, and resume ads if necessary.
    eventListener.onAdPlaybackState(adPlaybackState.copy());
    if (imaPausedContent && player.getPlayWhenReady()) {
      adsManager.resume();
    }
  } else if (adsManager != null) {
    // Ads have loaded but the ads manager is not initialized.
    startAdPlayback();
  } else {
    // Ads haven't loaded yet, so request them.
    requestAds(adUiViewGroup);
  }
}
项目:transistor    文件:AdsMediaSource.java   
@Override
public void prepareSource(final ExoPlayer player, boolean isTopLevelSource, Listener listener) {
  Assertions.checkArgument(isTopLevelSource);
  this.listener = listener;
  this.player = player;
  playerHandler = new Handler();
  contentMediaSource.prepareSource(player, false, new Listener() {
    @Override
    public void onSourceInfoRefreshed(MediaSource source, Timeline timeline, Object manifest) {
      AdsMediaSource.this.onContentSourceInfoRefreshed(timeline, manifest);
    }
  });
  mainHandler.post(new Runnable() {
    @Override
    public void run() {
      adsLoader.attachPlayer(player, componentListener, adUiViewGroup);
    }
  });
}
项目:transistor    文件:ConcatenatingMediaSource.java   
@Override
public void prepareSource(ExoPlayer player, boolean isTopLevelSource, Listener listener) {
  this.listener = listener;
  if (mediaSources.length == 0) {
    listener.onSourceInfoRefreshed(this, Timeline.EMPTY, null);
  } else {
    for (int i = 0; i < mediaSources.length; i++) {
      if (!duplicateFlags[i]) {
        final int index = i;
        mediaSources[i].prepareSource(player, false, new Listener() {
          @Override
          public void onSourceInfoRefreshed(MediaSource source, Timeline timeline,
              Object manifest) {
            handleSourceInfoRefreshed(index, timeline, manifest);
          }
        });
      }
    }
  }
}
项目:evercam-android    文件:VideoActivity.java   
/************************
 * ExoPlayer2.Listener
 ************************/
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {

    String text = "playWhenReady=" + playWhenReady + ", playbackState=";
    switch (playbackState) {
        case ExoPlayer.STATE_BUFFERING:
            text += "buffering";
            break;
        case ExoPlayer.STATE_ENDED:
            text += "ended";
            break;
        case ExoPlayer.STATE_IDLE:
            text += "idle";
            break;
        case ExoPlayer.STATE_READY:
            onVideoLoaded();
            text += "ready";
            break;
        default:
            text += "unknown";
            break;
    }
    Log.d(TAG, "onStateChanged: " + text);
}
项目:react-native-videoplayer    文件:ReactExoplayerView.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    String text = "onStateChanged: playWhenReady=" + playWhenReady + ", playbackState=";
    switch (playbackState) {
        case ExoPlayer.STATE_IDLE:
            text += "idle";
            eventEmitter.idle();
            break;
        case ExoPlayer.STATE_BUFFERING:
            text += "buffering";
            onBuffering(true);
            break;
        case ExoPlayer.STATE_READY:
            text += "ready";
            eventEmitter.ready();
            onBuffering(false);
            startProgressHandler();
            videoLoaded();
            break;
        case ExoPlayer.STATE_ENDED:
            text += "ended";
            eventEmitter.end();
            onStopPlayback();
            break;
        default:
            text += "unknown";
            break;
    }
    Log.d(TAG, text);
}
项目:UdacityBakingAndroid    文件:StepFragment.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    if((playbackState == ExoPlayer.STATE_READY) && playWhenReady){
        mStateBuilder.setState(PlaybackStateCompat.STATE_PLAYING,
                mExoPlayer.getCurrentPosition(), 1f);
    } else if((playbackState == ExoPlayer.STATE_READY)) {
        mStateBuilder.setState(PlaybackStateCompat.STATE_PAUSED,
                mExoPlayer.getCurrentPosition(), 1f);
    }
    mMediaSession.setPlaybackState(mStateBuilder.build());
}
项目:TubiPlayer    文件:TubiExoPlayerView.java   
private void maybeShowController(boolean isForced) {
    if (!useController || player == null) {
        return;
    }
    int playbackState = player.getPlaybackState();
    boolean showIndefinitely = playbackState == ExoPlayer.STATE_IDLE
            || playbackState == ExoPlayer.STATE_ENDED || !player.getPlayWhenReady();
    boolean wasShowingIndefinitely = controller.isVisible() && controller.getShowTimeoutMs() <= 0;
    controller.setShowTimeoutMs(showIndefinitely ? 0 : controllerShowTimeoutMs);
    if (isForced || showIndefinitely || wasShowingIndefinitely) {
        controller.show();
    }
}
项目:TubiPlayer    文件:TubiObservable.java   
private void updateProgress() {
    long position = player == null ? 0 : player.getCurrentPosition();
    long duration = player == null ? 0 : player.getDuration();
    setProgressBarMax((int) duration);
    if (!draggingSeekBar) {
        setProgressSeekTime(position, duration);
        setProgressBarValue(position);
    }
    long bufferedPosition = player == null ? 0 : player.getBufferedPosition();
    setSecondaryProgressBarValue(bufferedPosition);


    playbackControlInterface.cancelRunnable(updateProgressAction);
    // Schedule an update if necessary.
    int playbackState = player == null ? ExoPlayer.STATE_IDLE : player.getPlaybackState();
    if (playbackState != ExoPlayer.STATE_IDLE && playbackState != STATE_ENDED) {
        long delayMs;
        if (player.getPlayWhenReady() && playbackState == STATE_READY) {
            delayMs = 1000 - (position % 1000);
            if (delayMs < 200) {
                delayMs += 1000;
            }
        } else {
            delayMs = 1000;
        }
        if (playbackInterface.isActive()) {
            playbackControlInterface.postRunnable(updateProgressAction, delayMs);
        }
    }
}
项目:TubiPlayer    文件:TubiObservable.java   
public void setPlaybackState(int playbackState) {
    this.playbackState = playbackState;
    switch (playbackState) {
        case STATE_READY:
            setDraggingSeekBar(false);
            break;
        case ExoPlayer.STATE_BUFFERING:
        case ExoPlayer.STATE_IDLE:  //nothing to play
        case STATE_ENDED: //stream ended
            break;
    }

    notifyPropertyChanged(BR.playbackState);
}
项目:TubiPlayer    文件:AdPlayingMonitor.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    super.onPlayerStateChanged(playWhenReady, playbackState);

    //the last ad has finish playing.
    if (playbackState == ExoPlayer.STATE_ENDED && playWhenReady == true) {
        fsmPlayer.removePlayedAdAndTransitToNextState();
    }
}
项目:TubiPlayer    文件:MoviePlayingState.java   
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);
    }
项目:TubiPlayer    文件:EventLogger.java   
private static String getStateString(int state) {
  switch (state) {
    case ExoPlayer.STATE_BUFFERING:
      return "B";
    case ExoPlayer.STATE_ENDED:
      return "E";
    case ExoPlayer.STATE_IDLE:
      return "I";
    case ExoPlayer.STATE_READY:
      return "R";
    default:
      return "?";
  }
}
项目:ExoPlayer-Offline    文件:EventLogger.java   
private static String getStateString(int state) {
  switch (state) {
    case ExoPlayer.STATE_BUFFERING:
      return "B";
    case ExoPlayer.STATE_ENDED:
      return "E";
    case ExoPlayer.STATE_IDLE:
      return "I";
    case ExoPlayer.STATE_READY:
      return "R";
    default:
      return "?";
  }
}