Java Code Examples for com.google.android.exoplayer2.Player#setPlayWhenReady()
The following examples show how to use
com.google.android.exoplayer2.Player#setPlayWhenReady() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StoryView.java From zom-android-matrix with Apache License 2.0 | 6 votes |
private void setCurrentPage() { if (currentPageViewHolder != null) { if (currentPageViewHolder.itemView instanceof SimpleExoPlayerView) { Player player = ((SimpleExoPlayerView)currentPageViewHolder.itemView).getPlayer(); if (player != null) { player.setPlayWhenReady(false); } } } currentPage = getCurrentPagePosition(); currentPageViewHolder = (currentPage >= 0) ? getHistoryView().findViewHolderForAdapterPosition(currentPage) : null; if (currentPageViewHolder != null) { if (currentPageViewHolder.itemView instanceof SimpleExoPlayerView) { SimpleExoPlayerView playerView = (SimpleExoPlayerView) currentPageViewHolder.itemView; playerView.getPlayer().setPlayWhenReady(true); } else if (currentPageViewHolder.itemView instanceof PZSImageView) { getHistoryView().removeCallbacks(advanceToNextRunnable); getHistoryView().postDelayed(advanceToNextRunnable, AUTO_ADVANCE_TIMEOUT_IMAGE); } else if (currentPageViewHolder.itemView instanceof PDFView) { getHistoryView().removeCallbacks(advanceToNextRunnable); getHistoryView().postDelayed(advanceToNextRunnable, AUTO_ADVANCE_TIMEOUT_PDF); } } }
Example 2
Source File: FileViewFragment.java From lbry-android with MIT License | 5 votes |
private void setCurrentPlayer(Player currentPlayer) { if (this.currentPlayer == currentPlayer) { return; } // View management. if (currentPlayer == MainActivity.appPlayer) { //localPlayerView.setVisibility(View.VISIBLE); castControlView.hide(); ((ImageView) getView().findViewById(R.id.player_image_cast_toggle)).setImageResource(R.drawable.ic_cast); } else /* currentPlayer == castPlayer */ { castControlView.show(); ((ImageView) getView().findViewById(R.id.player_image_cast_toggle)).setImageResource(R.drawable.ic_cast_connected); } // Player state management. long playbackPositionMs = C.TIME_UNSET; int windowIndex = C.INDEX_UNSET; boolean playWhenReady = false; Player previousPlayer = this.currentPlayer; if (previousPlayer != null) { // Save state from the previous player. int playbackState = previousPlayer.getPlaybackState(); if (playbackState != Player.STATE_ENDED) { playbackPositionMs = previousPlayer.getCurrentPosition(); playWhenReady = previousPlayer.getPlayWhenReady(); } previousPlayer.stop(true); } this.currentPlayer = currentPlayer; // Media queue management. /*if (currentPlayer == exoPlayer) { exoPlayer.prepare(concatenatingMediaSource); }*/ currentPlayer.seekTo(playbackPositionMs); currentPlayer.setPlayWhenReady(true); }
Example 3
Source File: United.java From United4 with GNU General Public License v3.0 | 5 votes |
public static void onCompletion(Player player) { boolean looping = P.getBool("looping"); boolean shuffling = P.getBool("shuffle"); // If we're looping, play the song again if (looping) { player.seekTo(0); player.setPlayWhenReady(true); return; } int idx; try { // Get the list of all songs JSONArray parsed = new JSONArray(P.get("ordered_songs")); List<String> all_songs = new ArrayList<>(); for (int i = 0; i < parsed.length(); i++) { all_songs.add(parsed.getString(i)); } // If we're shuffling, get a random index if (shuffling) { idx = new Random().nextInt(all_songs.size()); } else { // otherwise, find the current index and add one idx = all_songs.indexOf(P.get("current_song")); idx = (idx + 1) % all_songs.size(); } // Figure out what song we're supposed to play String next_song = all_songs.get(idx); // Play it and notify music.html if it's up. For more information see the documentation for // NotifierService playSong(next_song, true); } catch (Exception ignored) { // } }