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

项目:yjPlay    文件:ImaAdsLoader.java   
@Override
public void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) {
  if (adsManager == null) {
    return;
  }
  if (!playingAd && !player.isPlayingAd()) {
    checkForContentComplete();
    if (sentContentComplete) {
      for (int i = 0; i < adPlaybackState.adGroupCount; i++) {
        if (adPlaybackState.adGroupTimesUs[i] != C.TIME_END_OF_SOURCE) {
          adPlaybackState.playedAdGroup(i);
        }
      }
      updateAdPlaybackState();
    } else {
      long positionMs = player.getCurrentPosition();
      timeline.getPeriod(0, period);
      if (period.getAdGroupIndexForPositionUs(C.msToUs(positionMs)) != C.INDEX_UNSET) {
        sentPendingContentPositionMs = false;
        pendingContentPositionMs = positionMs;
      }
    }
  } else {
    updateImaStateForPlayerState();
  }
}
项目:yjPlay    文件:PlaybackControlView.java   
/**
 * Sets which repeat toggle modes are enabled.
 *
 * @param repeatToggleModes A set of {@link RepeatModeUtil.RepeatToggleModes}.
 */
public void setRepeatToggleModes(@RepeatModeUtil.RepeatToggleModes int repeatToggleModes) {
    this.repeatToggleModes = repeatToggleModes;
    if (player != null) {
        @Player.RepeatMode int currentMode = player.getRepeatMode();
        if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE
                && currentMode != Player.REPEAT_MODE_OFF) {
            controlDispatcher.dispatchSetRepeatMode(player, Player.REPEAT_MODE_OFF);
        } else if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_ONE
                && currentMode == Player.REPEAT_MODE_ALL) {
            controlDispatcher.dispatchSetRepeatMode(player, Player.REPEAT_MODE_ONE);
        } else if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL
                && currentMode == Player.REPEAT_MODE_ONE) {
            controlDispatcher.dispatchSetRepeatMode(player, Player.REPEAT_MODE_ALL);
        }
    }
}
项目:yjPlay    文件:DebugTextViewHelper.java   
private String getPlayerStateString() {
  String text = "playWhenReady:" + player.getPlayWhenReady() + " playbackState:";
  switch (player.getPlaybackState()) {
    case Player.STATE_BUFFERING:
      text += "buffering";
      break;
    case Player.STATE_ENDED:
      text += "ended";
      break;
    case Player.STATE_IDLE:
      text += "idle";
      break;
    case Player.STATE_READY:
      text += "ready";
      break;
    default:
      text += "unknown";
      break;
  }
  return text;
}
项目:exoplayer-intro    文件:PlayerActivity.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
  String stateString;
  switch (playbackState) {
    case Player.STATE_IDLE:
      stateString = "ExoPlayer.STATE_IDLE      -";
      break;
    case Player.STATE_BUFFERING:
      stateString = "ExoPlayer.STATE_BUFFERING -";
      break;
    case Player.STATE_READY:
      stateString = "ExoPlayer.STATE_READY     -";
      break;
    case Player.STATE_ENDED:
      stateString = "ExoPlayer.STATE_ENDED     -";
      break;
    default:
      stateString = "UNKNOWN_STATE             -";
      break;
  }
  Log.d(TAG, "changed state to " + stateString + " playWhenReady: " + playWhenReady);
}
项目:exoplayer-intro    文件:PlayerActivity.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
  String stateString;
  switch (playbackState) {
    case Player.STATE_IDLE:
      stateString = "ExoPlayer.STATE_IDLE      -";
      break;
    case Player.STATE_BUFFERING:
      stateString = "ExoPlayer.STATE_BUFFERING -";
      break;
    case Player.STATE_READY:
      stateString = "ExoPlayer.STATE_READY     -";
      break;
    case Player.STATE_ENDED:
      stateString = "ExoPlayer.STATE_ENDED     -";
      break;
    default:
      stateString = "UNKNOWN_STATE             -";
      break;
  }
  Log.d(TAG, "changed state to " + stateString + " playWhenReady: " + playWhenReady);
}
项目:chaosflix    文件:MyListener.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    switch (playbackState) {
        case Player.STATE_BUFFERING:
            if (player.isLoading()) {
                listener.notifyLoadingStart();
            }
            break;
        case Player.STATE_ENDED:
            Log.d(TAG, "Finished Playback");

            break;
        case Player.STATE_IDLE:
        case Player.STATE_READY:
        default:
            listener.notifyLoadingFinished();
    }
}
项目:tumbviewer    文件:CommonExoPlayerView.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    Log.d("onPlayerStateChanged", playWhenReady + "-" + playbackState);
    if (playbackState == Player.STATE_BUFFERING) {
        loadingBar.setVisibility(VISIBLE);
    } else if (playbackState == Player.STATE_ENDED) {
        show();
        playerInstance.abandonAudioFocus();
        loadingBar.setVisibility(GONE);
    } else {
        loadingBar.setVisibility(GONE);
    }
    updatePlayPauseButton();
    updateProgress();
    updateLeftTime();
}
项目:NSMPlayer-Android    文件:WrapExoPlayer.java   
@Override
public boolean isPlaying() {
    if (mInternalMediaPlayer == null) {
        return false;
    }

    int state = mInternalMediaPlayer.getPlaybackState();
    switch (state) {
        case Player.STATE_BUFFERING:
        case Player.STATE_READY:
            return mInternalMediaPlayer.getPlayWhenReady();
        case Player.STATE_IDLE:
        case Player.STATE_ENDED:
        default:
            return false;
    }
}
项目:projectBlue    文件:ExoPlayerPlaybackHandler.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    logger.debug("Playback state has changed to " + playbackState);

    if (isPlaying && playbackState == Player.STATE_IDLE) {
        logger.warn("The player was playing, but it transitioned to idle! Restarting the player...");
        pause();
        exoPlayer.setPlayWhenReady(true);
    }

    if (playbackState != Player.STATE_ENDED) return;

    isPlaying = false;

    playbackHandlerMessenger.sendResolution(this);
    exoPlayer.removeListener(this);
}
项目:transistor    文件:ImaAdsLoader.java   
@Override
public void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) {
  if (adsManager == null) {
    return;
  }
  if (!playingAd && !player.isPlayingAd()) {
    checkForContentComplete();
    if (sentContentComplete) {
      for (int i = 0; i < adPlaybackState.adGroupCount; i++) {
        if (adPlaybackState.adGroupTimesUs[i] != C.TIME_END_OF_SOURCE) {
          adPlaybackState.playedAdGroup(i);
        }
      }
      updateAdPlaybackState();
    } else {
      long positionMs = player.getCurrentPosition();
      timeline.getPeriod(0, period);
      if (period.getAdGroupIndexForPositionUs(C.msToUs(positionMs)) != C.INDEX_UNSET) {
        sentPendingContentPositionMs = false;
        pendingContentPositionMs = positionMs;
      }
    }
  } else {
    updateImaStateForPlayerState();
  }
}
项目:transistor    文件:ExoPlayerTestRunner.java   
private ExoPlayerTestRunner(PlayerFactory playerFactory, MediaSource mediaSource,
    RenderersFactory renderersFactory, MappingTrackSelector trackSelector,
    LoadControl loadControl, ActionSchedule actionSchedule, Player.EventListener eventListener) {
  this.playerFactory = playerFactory;
  this.mediaSource = mediaSource;
  this.renderersFactory = renderersFactory;
  this.trackSelector = trackSelector;
  this.loadControl = loadControl;
  this.actionSchedule = actionSchedule;
  this.eventListener = eventListener;
  this.timelines = new LinkedList<>();
  this.manifests = new LinkedList<>();
  this.periodIndices = new LinkedList<>();
  this.endedCountDownLatch = new CountDownLatch(1);
  this.playerThread = new HandlerThread("ExoPlayerTest thread");
  playerThread.start();
  this.handler = new Handler(playerThread.getLooper());
}
项目:transistor    文件:LoopingMediaSourceTest.java   
public void testSingleLoop() {
  Timeline timeline = getLoopingTimeline(multiWindowTimeline, 1);
  TimelineAsserts.assertWindowIds(timeline, 111, 222, 333);
  TimelineAsserts.assertPeriodCounts(timeline, 1, 1, 1);
  for (boolean shuffled : new boolean[] {false, true}) {
    TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, shuffled,
        C.INDEX_UNSET, 0, 1);
    TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, shuffled,
        0, 1, 2);
    TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, shuffled,
        2, 0, 1);
    TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, shuffled,
        1, 2, C.INDEX_UNSET);
    TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, shuffled, 0, 1, 2);
    TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, shuffled, 1, 2, 0);
  }
}
项目:transistor    文件:LoopingMediaSourceTest.java   
public void testInfiniteLoop() {
  Timeline timeline = getLoopingTimeline(multiWindowTimeline, Integer.MAX_VALUE);
  TimelineAsserts.assertWindowIds(timeline, 111, 222, 333);
  TimelineAsserts.assertPeriodCounts(timeline, 1, 1, 1);
  for (boolean shuffled : new boolean[] {false, true}) {
    TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, shuffled,
        2, 0, 1);
    TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, shuffled,
        0, 1, 2);
    TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, shuffled,
        2, 0, 1);
    TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, shuffled, 1, 2, 0);
    TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, shuffled, 0, 1, 2);
    TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, shuffled, 1, 2, 0);
  }
}
项目:transistor    文件:MediaSessionConnector.java   
/**
 * Sets the player to be connected to the media session.
 * <p>
 * The order in which any {@link CustomActionProvider}s are passed determines the order of the
 * actions published with the playback state of the session.
 *
 * @param player The player to be connected to the {@code MediaSession}.
 * @param playbackPreparer An optional {@link PlaybackPreparer} for preparing the player.
 * @param customActionProviders An optional {@link CustomActionProvider}s to publish and handle
 *     custom actions.
 */
public void setPlayer(Player player, PlaybackPreparer playbackPreparer,
    CustomActionProvider... customActionProviders) {
  if (this.player != null) {
    this.player.removeListener(exoPlayerEventListener);
    mediaSession.setCallback(null);
  }
  unregisterCommandReceiver(this.playbackPreparer);

  this.player = player;
  this.playbackPreparer = playbackPreparer;
  registerCommandReceiver(playbackPreparer);

  this.customActionProviders = (player != null && customActionProviders != null)
      ? customActionProviders : new CustomActionProvider[0];
  if (player != null) {
    mediaSession.setCallback(mediaSessionCallback, handler);
    player.addListener(exoPlayerEventListener);
  }
  updateMediaSessionPlaybackState();
  updateMediaSessionMetadata();
}
项目:transistor    文件:PlaybackControlView.java   
/**
 * Sets which repeat toggle modes are enabled.
 *
 * @param repeatToggleModes A set of {@link RepeatModeUtil.RepeatToggleModes}.
 */
public void setRepeatToggleModes(@RepeatModeUtil.RepeatToggleModes int repeatToggleModes) {
  this.repeatToggleModes = repeatToggleModes;
  if (player != null) {
    @Player.RepeatMode int currentMode = player.getRepeatMode();
    if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE
        && currentMode != Player.REPEAT_MODE_OFF) {
      controlDispatcher.dispatchSetRepeatMode(player, Player.REPEAT_MODE_OFF);
    } else if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_ONE
        && currentMode == Player.REPEAT_MODE_ALL) {
      controlDispatcher.dispatchSetRepeatMode(player, Player.REPEAT_MODE_ONE);
    } else if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL
        && currentMode == Player.REPEAT_MODE_ONE) {
      controlDispatcher.dispatchSetRepeatMode(player, Player.REPEAT_MODE_ALL);
    }
  }
}
项目:transistor    文件:TimelineQueueNavigator.java   
@Override
public long getSupportedQueueNavigatorActions(Player player) {
  if (player == null || player.getCurrentTimeline().getWindowCount() < 2) {
    return 0;
  }
  if (player.getRepeatMode() != Player.REPEAT_MODE_OFF) {
    return PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS
        | PlaybackStateCompat.ACTION_SKIP_TO_QUEUE_ITEM;
  }

  int currentWindowIndex = player.getCurrentWindowIndex();
  long actions;
  if (currentWindowIndex == 0) {
    actions = PlaybackStateCompat.ACTION_SKIP_TO_NEXT;
  } else if (currentWindowIndex == player.getCurrentTimeline().getWindowCount() - 1) {
    actions = PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS;
  } else {
    actions = PlaybackStateCompat.ACTION_SKIP_TO_NEXT
        | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS;
  }
  return actions | PlaybackStateCompat.ACTION_SKIP_TO_QUEUE_ITEM;
}
项目:transistor    文件:TimelineQueueNavigator.java   
private void publishFloatingQueueWindow(Player player) {
  if (player.getCurrentTimeline().isEmpty()) {
    mediaSession.setQueue(Collections.<MediaSessionCompat.QueueItem>emptyList());
    activeQueueItemId = MediaSessionCompat.QueueItem.UNKNOWN_ID;
    return;
  }
  int windowCount = player.getCurrentTimeline().getWindowCount();
  int currentWindowIndex = player.getCurrentWindowIndex();
  int queueSize = Math.min(maxQueueSize, windowCount);
  int startIndex = Util.constrainValue(currentWindowIndex - ((queueSize - 1) / 2), 0,
      windowCount - queueSize);
  List<MediaSessionCompat.QueueItem> queue = new ArrayList<>();
  for (int i = startIndex; i < startIndex + queueSize; i++) {
    queue.add(new MediaSessionCompat.QueueItem(getMediaDescription(i), i));
  }
  mediaSession.setQueue(queue);
  activeQueueItemId = currentWindowIndex;
}
项目:transistor    文件:RepeatModeActionProvider.java   
@Override
public PlaybackStateCompat.CustomAction getCustomAction() {
  CharSequence actionLabel;
  int iconResourceId;
  switch (player.getRepeatMode()) {
    case Player.REPEAT_MODE_ONE:
      actionLabel = repeatOneDescription;
      iconResourceId = R.drawable.exo_media_action_repeat_one;
      break;
    case Player.REPEAT_MODE_ALL:
      actionLabel = repeatAllDescription;
      iconResourceId = R.drawable.exo_media_action_repeat_all;
      break;
    case Player.REPEAT_MODE_OFF:
    default:
      actionLabel = repeatOffDescription;
      iconResourceId = R.drawable.exo_media_action_repeat_off;
      break;
  }
  PlaybackStateCompat.CustomAction.Builder repeatBuilder = new PlaybackStateCompat.CustomAction
      .Builder(ACTION_REPEAT_MODE, actionLabel, iconResourceId);
  return repeatBuilder.build();
}
项目:transistor    文件:FakeSimpleExoPlayer.java   
public FakeExoPlayer(Renderer[] renderers, TrackSelector trackSelector,
    LoadControl loadControl) {
  this.renderers = renderers;
  this.trackSelector = trackSelector;
  this.loadControl = loadControl;
  this.eventListeners = new CopyOnWriteArraySet<>();
  Looper eventListenerLooper = Looper.myLooper();
  this.eventListenerHandler = new Handler(eventListenerLooper != null ? eventListenerLooper
      : Looper.getMainLooper());
  this.playbackThread = new HandlerThread("FakeExoPlayer Thread");
  playbackThread.start();
  this.playbackHandler = new Handler(playbackThread.getLooper());
  this.isStartingUp = true;
  this.isLoading = false;
  this.playbackState = Player.STATE_IDLE;
  this.durationUs = C.TIME_UNSET;
}
项目:transistor    文件:FakeSimpleExoPlayer.java   
@Override
public void onSourceInfoRefreshed(MediaSource source, final Timeline timeline,
    final @Nullable Object manifest) {
  if (this.timeline != null) {
    throw new UnsupportedOperationException();
  }
  Assertions.checkArgument(timeline.getPeriodCount() == 1);
  Assertions.checkArgument(timeline.getWindowCount() == 1);
  final ConditionVariable waitForNotification = new ConditionVariable();
  eventListenerHandler.post(new Runnable() {
    @Override
    public void run() {
      for (Player.EventListener eventListener : eventListeners) {
        FakeExoPlayer.this.durationUs = timeline.getPeriod(0, new Period()).durationUs;
        FakeExoPlayer.this.timeline = timeline;
        FakeExoPlayer.this.manifest = manifest;
        eventListener.onTimelineChanged(timeline, manifest);
        waitForNotification.open();
      }
    }
  });
  waitForNotification.block();
  this.mediaPeriod = mediaSource.createPeriod(new MediaPeriodId(0), loadControl.getAllocator());
  mediaPeriod.prepare(this, 0);
}
项目:transistor    文件:FakeSimpleExoPlayer.java   
private void maybeContinueLoading() {
  boolean newIsLoading = false;
  long nextLoadPositionUs = mediaPeriod.getNextLoadPositionUs();
  if (nextLoadPositionUs != C.TIME_END_OF_SOURCE) {
    long bufferedDurationUs = nextLoadPositionUs - rendererPositionUs;
    if (loadControl.shouldContinueLoading(bufferedDurationUs)) {
      newIsLoading = true;
      mediaPeriod.continueLoading(rendererPositionUs);
    }
  }
  if (newIsLoading != isLoading) {
    isLoading = newIsLoading;
    eventListenerHandler.post(new Runnable() {
      @Override
      public void run() {
        for (Player.EventListener eventListener : eventListeners) {
          eventListener.onLoadingChanged(isLoading);
        }
      }
    });
  }
}
项目:transistor    文件:Action.java   
@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);
  }
}
项目:transistor    文件:Action.java   
@Override
protected void doActionAndScheduleNextImpl(final SimpleExoPlayer player,
    final MappingTrackSelector trackSelector, final Surface surface, final Handler handler,
    final ActionNode nextAction) {
  if (nextAction == null) {
    return;
  }
  if (targetPlaybackState == player.getPlaybackState()) {
    nextAction.schedule(player, trackSelector, surface, handler);
  } else {
    player.addListener(new Player.DefaultEventListener() {
      @Override
      public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
        if (targetPlaybackState == playbackState) {
          player.removeListener(this);
          nextAction.schedule(player, trackSelector, surface, handler);
        }
      }
    });
  }
}
项目:yjPlay    文件:ImaAdsLoader.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
  if (adsManager == null) {
    return;
  }

  if (imaAdState == IMA_AD_STATE_PLAYING && !playWhenReady) {
    adsManager.pause();
    return;
  }

  if (imaAdState == IMA_AD_STATE_PAUSED && playWhenReady) {
    adsManager.resume();
    return;
  }

  if (imaAdState == IMA_AD_STATE_NONE && playbackState == Player.STATE_BUFFERING
      && playWhenReady) {
    checkForContentComplete();
  } else if (imaAdState != IMA_AD_STATE_NONE && playbackState == Player.STATE_ENDED) {
    // IMA is waiting for the ad playback to finish so invoke the callback now.
    // Either CONTENT_RESUME_REQUESTED will be passed next, or playAd will be called again.
    for (int i = 0; i < adCallbacks.size(); i++) {
      adCallbacks.get(i).onEnded();
    }
  }
}
项目:yjPlay    文件:ExoUserPlayer.java   
/***
 * 是否播放中
 * @return boolean boolean
 */
public boolean isPlaying() {
    if (player == null) return false;
    int playbackState = player.getPlaybackState();
    return playbackState != Player.STATE_IDLE && playbackState != Player.STATE_ENDED
            && player.getPlayWhenReady();
}
项目:yjPlay    文件:PlaybackControlView.java   
/**
 * Sets the {@link Player} to control.
 *
 * @param player The {@link Player} to control.
 */
public void setPlayer(Player player) {
    if (this.player == player) {
        return;
    }
    if (this.player != null) {
        this.player.removeListener(componentListener);
    }
    this.player = player;
    if (player != null) {
        player.addListener(componentListener);
    }
    updateAll();
}
项目:yjPlay    文件:PlaybackControlView.java   
private void updateRepeatModeButton() {
    if (!isVisible() || !isAttachedToWindow || repeatToggleButton == null) {
        return;
    }
    if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE) {
        repeatToggleButton.setVisibility(View.GONE);
        return;
    }
    if (player == null) {
        setButtonEnabled(false, repeatToggleButton);
        return;
    }
    setButtonEnabled(true, repeatToggleButton);
    switch (player.getRepeatMode()) {
        case Player.REPEAT_MODE_OFF:
            repeatToggleButton.setImageDrawable(repeatOffButtonDrawable);
            repeatToggleButton.setContentDescription(repeatOffButtonContentDescription);
            break;
        case Player.REPEAT_MODE_ONE:
            repeatToggleButton.setImageDrawable(repeatOneButtonDrawable);
            repeatToggleButton.setContentDescription(repeatOneButtonContentDescription);
            break;
        case Player.REPEAT_MODE_ALL:
            repeatToggleButton.setImageDrawable(repeatAllButtonDrawable);
            repeatToggleButton.setContentDescription(repeatAllButtonContentDescription);
            break;
    }
    repeatToggleButton.setVisibility(View.VISIBLE);
}
项目:yjPlay    文件:SimpleExoPlayerView.java   
public boolean shouldShowControllerIndefinitely() {
    if (player == null) {
        return true;
    }
    int playbackState = player.getPlaybackState();
    return controllerAutoShow && (playbackState == Player.STATE_IDLE
            || playbackState == Player.STATE_ENDED || !player.getPlayWhenReady());
}
项目:Phoenix-for-VK    文件:ExoVoicePlayer.java   
private void onInternalPlayerStateChanged(int state) {
    Logger.d("ExoVoicePlayer", "onInternalPlayerStateChanged, state: " + state);

    switch (state){
        case Player.STATE_READY:
            setStatus(STATUS_PREPARED);
            break;
        case Player.STATE_ENDED:
            setSupposedToBePlaying(false);
            exoPlayer.seekTo(0);
            break;
    }
}
项目:BakingApp    文件:StepDetailFragment.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    if (playbackState == Player.STATE_READY && playWhenReady) {
        mStateBuilder.setState(PlaybackStateCompat.STATE_PLAYING, mExoPlayer.getCurrentPosition(), 1f);
        mBinding.pbBufferingIndicator.setVisibility(View.GONE);
    } else if (playbackState == Player.STATE_READY) {
        mStateBuilder.setState(PlaybackStateCompat.STATE_PAUSED, mExoPlayer.getCurrentPosition(), 1f);
        mBinding.pbBufferingIndicator.setVisibility(View.GONE);
    } else if (playbackState == Player.STATE_BUFFERING) {
        mBinding.pbBufferingIndicator.setVisibility(View.VISIBLE);
    } else {
        mBinding.pbBufferingIndicator.setVisibility(View.GONE);
    }
    mMediaSession.setPlaybackState(mStateBuilder.build());
}
项目:chaosflix    文件:MyListener.java   
@Override
public void onLoadingChanged(boolean isLoading) {
    if (isLoading && player.getPlaybackState() != Player.STATE_READY) {
        listener.notifyLoadingStart();
    } else {
        listener.notifyLoadingFinished();
    }

}
项目:NSMPlayer-Android    文件:WrapExoPlayer.java   
/**
 * Called when the value returned from either {@link ExoPlayer#getPlayWhenReady()} or
 * {@link ExoPlayer#getPlaybackState()} changes.
 *
 * @param playWhenReady Whether playback will proceed when ready.
 * @param playbackState One of the {@code STATE} constants defined in the {@link ExoPlayer}
 *     interface.
 */
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    if (mInternalMediaPlayer == null) {
        PlayerLog.d(TAG, "onPlayerStateChanged mInternalMediaPlayer == null");
        return;
    }
    mInternalPlayerState = playbackState;
    if (isBuffering) {
        switch (playbackState) {
            case Player.STATE_ENDED:
            case Player.STATE_READY:
                notifyOnInfo(IInternalPlayer.MEDIA_INFO_BUFFERING_END, getBufferedPercentage());
                isBuffering = false;
                break;
        }
    }
    switch (playbackState) {
        case Player.STATE_IDLE:
            PlayerLog.d(TAG, "WrapExoPlayer.STATE_IDLE");
            break;
        case Player.STATE_BUFFERING:
            PlayerLog.d(TAG, "WrapExoPlayer.STATE_BUFFERING");
            notifyOnInfo(IInternalPlayer.MEDIA_INFO_BUFFERING_START, getBufferedPercentage());
            isBuffering = true;
            break;
        case Player.STATE_READY:
            PlayerLog.d(TAG, "WrapExoPlayer.STATE_READY");
            break;
        case Player.STATE_ENDED:
            PlayerLog.d(TAG, "WrapExoPlayer.STATE_ENDED");
            notifyOnCompletion();
            break;
    }
}
项目:GSYVideoPlayer    文件:IjkExo2MediaPlayer.java   
@Override
public boolean isPlaying() {
    if (mInternalPlayer == null)
        return false;
    int state = mInternalPlayer.getPlaybackState();
    switch (state) {
        case Player.STATE_BUFFERING:
        case Player.STATE_READY:
            return mInternalPlayer.getPlayWhenReady();
        case Player.STATE_IDLE:
        case Player.STATE_ENDED:
        default:
            return false;
    }
}
项目:GSYVideoPlayer    文件:EventLogger.java   
private static String getStateString(int state) {
  switch (state) {
    case Player.STATE_BUFFERING:
      return "B";
    case Player.STATE_ENDED:
      return "E";
    case Player.STATE_IDLE:
      return "I";
    case Player.STATE_READY:
      return "R";
    default:
      return "?";
  }
}
项目:GSYVideoPlayer    文件:EventLogger.java   
private static String getRepeatModeString(@Player.RepeatMode int repeatMode) {
  switch (repeatMode) {
    case Player.REPEAT_MODE_OFF:
      return "OFF";
    case Player.REPEAT_MODE_ONE:
      return "ONE";
    case Player.REPEAT_MODE_ALL:
      return "ALL";
    default:
      return "?";
  }
}
项目:GSYVideoPlayer    文件:EventLogger.java   
private static String getDiscontinuityReasonString(@Player.DiscontinuityReason int reason) {
  switch (reason) {
    case Player.DISCONTINUITY_REASON_PERIOD_TRANSITION:
      return "PERIOD_TRANSITION";
    case Player.DISCONTINUITY_REASON_SEEK:
      return "SEEK";
    case Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT:
      return "SEEK_ADJUSTMENT";
    case Player.DISCONTINUITY_REASON_INTERNAL:
      return "INTERNAL";
    default:
      return "?";
  }
}
项目:no-player    文件:BufferStateForwarder.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    if (playbackState == Player.STATE_BUFFERING) {
        bufferStateListener.onBufferStarted();
    } else if (playbackState == Player.STATE_READY) {
        bufferStateListener.onBufferCompleted();
    }
}
项目:no-player    文件:EventInfoForwarder.java   
@Override
public void onRepeatModeChanged(@Player.RepeatMode int repeatMode) {
    HashMap<String, String> callingMethodParameters = new HashMap<>();

    callingMethodParameters.put("repeatMode", String.valueOf(repeatMode));

    infoListener.onNewInfo("onRepeatModeChanged", callingMethodParameters);
}
项目:ExoPlayerVideoView    文件:ExoVideoView.java   
private void maybeShowController(boolean isForced) {
    if (!useController || player == null) {
        return;
    }
    int playbackState = player.getPlaybackState();
    boolean showIndefinitely = playbackState == Player.STATE_IDLE
            || playbackState == Player.STATE_ENDED || !player.getPlayWhenReady();
    boolean wasShowingIndefinitely = controller.isVisible() && controller.getShowTimeoutMs() <= 0;
    controller.setShowTimeoutMs(showIndefinitely ? 0 : controllerShowTimeoutMs);
    if (isForced || showIndefinitely || wasShowingIndefinitely) {
        controller.show();
    }
}
项目:ExoPlayerVideoView    文件:ExoVideoPlaybackControlView.java   
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    updatePlayPauseButton();
    updateProgress();
    if (playbackState == Player.STATE_IDLE || playbackState == Player.STATE_BUFFERING) {
        showUntilHideCalled();
        showLoading(true);
    } else if (playbackState == Player.STATE_READY && player.getPlayWhenReady() || playbackState == Player.STATE_ENDED) {
        showLoading(false);
        hide();
    }
}