Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ android {

defaultConfig {
applicationId "InfinityLoop1309.NewPipeEnhanced"
minSdk 21
// media3 1.9+ requires API 23 (media3-session). Bumped from 21 -> drops Android 5.0/5.1.
minSdk 23
//noinspection ExpiredTargetSdkVersion
targetSdk 33
versionCode 1100
Expand Down Expand Up @@ -137,7 +138,7 @@ ext {
androidxRoomVersion = '2.4.2'
androidxWorkVersion = '2.10.2'

exoPlayerVersion = '2.18.7'
media3Version = '1.10.1'
googleAutoServiceVersion = '1.0.1'
groupieVersion = '2.10.0'
markwonVersion = '4.6.2'
Expand Down Expand Up @@ -271,8 +272,14 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:3.12.13"

// Media player
implementation "com.google.android.exoplayer:exoplayer:${exoPlayerVersion}"
implementation "com.google.android.exoplayer:extension-mediasession:${exoPlayerVersion}"
implementation "androidx.media3:media3-exoplayer:${media3Version}"
implementation "androidx.media3:media3-exoplayer-dash:${media3Version}"
implementation "androidx.media3:media3-exoplayer-hls:${media3Version}"
implementation "androidx.media3:media3-exoplayer-smoothstreaming:${media3Version}"
implementation "androidx.media3:media3-datasource:${media3Version}"
implementation "androidx.media3:media3-ui:${media3Version}"
implementation "androidx.media3:media3-session:${media3Version}"
implementation "androidx.media3:media3-common:${media3Version}"

// Metadata generator for service descriptors
compileOnly "com.google.auto.service:auto-service-annotations:${googleAutoServiceVersion}"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/schabi/newpipe/error/ErrorInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.schabi.newpipe.error

import android.os.Parcelable
import androidx.annotation.StringRes
import com.google.android.exoplayer2.ExoPlaybackException
import androidx.media3.exoplayer.ExoPlaybackException
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import org.schabi.newpipe.R
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;

import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.PlaybackParameters;
import androidx.media3.common.PlaybackException;
import androidx.media3.common.PlaybackParameters;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.tabs.TabLayout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;

import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.PlaybackException;
import androidx.media3.common.C;
import androidx.media3.exoplayer.ExoPlaybackException;
import androidx.media3.common.PlaybackException;

import org.schabi.newpipe.R;
import org.schabi.newpipe.databinding.ListRadioIconItemBinding;
Expand All @@ -29,9 +29,9 @@
import java.util.Map;
import java.util.function.Supplier;

import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW;
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_DECODING_FAILED;
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_UNSPECIFIED;
import static androidx.media3.common.PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW;
import static androidx.media3.common.PlaybackException.ERROR_CODE_DECODING_FAILED;
import static androidx.media3.common.PlaybackException.ERROR_CODE_UNSPECIFIED;

/**
* Outsourced logic for crashing the player in the {@link VideoDetailFragment}.
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import java.util.List;

import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
import static com.google.android.exoplayer2.Player.REPEAT_MODE_ALL;
import static com.google.android.exoplayer2.Player.REPEAT_MODE_ONE;
import static androidx.media3.common.Player.REPEAT_MODE_ALL;
import static androidx.media3.common.Player.REPEAT_MODE_ONE;
import static org.schabi.newpipe.player.PlayerService.ACTION_CLOSE;
import static org.schabi.newpipe.player.PlayerService.ACTION_FAST_FORWARD;
import static org.schabi.newpipe.player.PlayerService.ACTION_FAST_REWIND;
Expand Down Expand Up @@ -269,19 +269,19 @@ private NotificationCompat.Action getAction(

case NotificationConstants.SMART_REWIND_PREVIOUS:
if (player.getPlayQueue() != null && player.getPlayQueue().size() > 1) {
return getAction(player, R.drawable.exo_notification_previous,
return getAction(player, R.drawable.exo_icon_previous,
R.string.exo_controls_previous_description, ACTION_PLAY_PREVIOUS);
} else {
return getAction(player, R.drawable.exo_controls_rewind,
return getAction(player, R.drawable.exo_icon_rewind,
R.string.exo_controls_rewind_description, ACTION_FAST_REWIND);
}

case NotificationConstants.SMART_FORWARD_NEXT:
if (player.getPlayQueue() != null && player.getPlayQueue().size() > 1) {
return getAction(player, R.drawable.exo_notification_next,
return getAction(player, R.drawable.exo_icon_next,
R.string.exo_controls_next_description, ACTION_PLAY_NEXT);
} else {
return getAction(player, R.drawable.exo_controls_fastforward,
return getAction(player, R.drawable.exo_icon_fastforward,
R.string.exo_controls_fastforward_description, ACTION_FAST_FORWARD);
}

Expand All @@ -303,10 +303,10 @@ private NotificationCompat.Action getAction(
|| player.getCurrentState() == Player.STATE_PREFLIGHT
|| player.getCurrentState() == Player.STATE_BLOCKED
|| player.getCurrentState() == Player.STATE_BUFFERING) {
return getAction(player, R.drawable.exo_notification_pause,
return getAction(player, R.drawable.exo_icon_pause,
R.string.exo_controls_pause_description, ACTION_PLAY_PAUSE);
} else {
return getAction(player, R.drawable.exo_notification_play,
return getAction(player, R.drawable.exo_icon_play,
R.string.exo_controls_play_description, ACTION_PLAY_PAUSE);
}

Expand All @@ -324,10 +324,10 @@ private NotificationCompat.Action getAction(

case NotificationConstants.SHUFFLE:
if (player.getPlayQueue() != null && player.getPlayQueue().isShuffled()) {
return getAction(player, R.drawable.exo_controls_shuffle_on,
return getAction(player, R.drawable.exo_icon_shuffle_on,
R.string.exo_controls_shuffle_on_description, ACTION_SHUFFLE);
} else {
return getAction(player, R.drawable.exo_controls_shuffle_off,
return getAction(player, R.drawable.exo_icon_shuffle_off,
R.string.exo_controls_shuffle_off_description, ACTION_SHUFFLE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.exoplayer2.PlaybackParameters;
import androidx.media3.common.PlaybackParameters;

import org.schabi.newpipe.R;
import org.schabi.newpipe.databinding.ActivityPlayerQueueControlBinding;
Expand Down Expand Up @@ -553,17 +553,17 @@ private void onStateChanged(final int state) {

private void onPlayModeChanged(final int repeatMode, final boolean shuffled) {
switch (repeatMode) {
case com.google.android.exoplayer2.Player.REPEAT_MODE_OFF:
case androidx.media3.common.Player.REPEAT_MODE_OFF:
queueControlBinding.controlRepeat
.setImageResource(R.drawable.exo_controls_repeat_off);
.setImageResource(R.drawable.exo_icon_repeat_off);
break;
case com.google.android.exoplayer2.Player.REPEAT_MODE_ONE:
case androidx.media3.common.Player.REPEAT_MODE_ONE:
queueControlBinding.controlRepeat
.setImageResource(R.drawable.exo_controls_repeat_one);
.setImageResource(R.drawable.exo_icon_repeat_one);
break;
case com.google.android.exoplayer2.Player.REPEAT_MODE_ALL:
case androidx.media3.common.Player.REPEAT_MODE_ALL:
queueControlBinding.controlRepeat
.setImageResource(R.drawable.exo_controls_repeat_all);
.setImageResource(R.drawable.exo_icon_repeat_all);
break;
}

Expand Down
91 changes: 46 additions & 45 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package org.schabi.newpipe.player;

import static com.google.android.exoplayer2.PlaybackException.*;
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_AUTO_TRANSITION;
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_INTERNAL;
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_REMOVE;
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_SEEK;
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT;
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_SKIP;
import static com.google.android.exoplayer2.Player.DiscontinuityReason;
import static com.google.android.exoplayer2.Player.Listener;
import static com.google.android.exoplayer2.Player.REPEAT_MODE_ALL;
import static com.google.android.exoplayer2.Player.REPEAT_MODE_OFF;
import static com.google.android.exoplayer2.Player.REPEAT_MODE_ONE;
import static com.google.android.exoplayer2.Player.RepeatMode;
import static androidx.media3.common.PlaybackException.*;
import static androidx.media3.common.Player.DISCONTINUITY_REASON_AUTO_TRANSITION;
import static androidx.media3.common.Player.DISCONTINUITY_REASON_INTERNAL;
import static androidx.media3.common.Player.DISCONTINUITY_REASON_REMOVE;
import static androidx.media3.common.Player.DISCONTINUITY_REASON_SEEK;
import static androidx.media3.common.Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT;
import static androidx.media3.common.Player.DISCONTINUITY_REASON_SKIP;
import static androidx.media3.common.Player.DiscontinuityReason;
import static androidx.media3.common.Player.Listener;
import static androidx.media3.common.Player.REPEAT_MODE_ALL;
import static androidx.media3.common.Player.REPEAT_MODE_OFF;
import static androidx.media3.common.Player.REPEAT_MODE_ONE;
import static androidx.media3.common.Player.RepeatMode;
import static org.schabi.newpipe.QueueItemMenuUtil.openPopupMenu;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
Expand Down Expand Up @@ -78,22 +78,23 @@
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.exoplayer2.*;
import com.google.android.exoplayer2.Player.PositionInfo;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Tracks;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.text.CueGroup;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.CaptionStyleCompat;
import com.google.android.exoplayer2.ui.SubtitleView;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoSize;
import androidx.media3.common.*;
import androidx.media3.exoplayer.*;
import androidx.media3.common.Player.PositionInfo;
import androidx.media3.common.Timeline;
import androidx.media3.common.Tracks;
import androidx.media3.exoplayer.source.MediaSource;
import androidx.media3.common.TrackGroup;
import androidx.media3.exoplayer.source.TrackGroupArray;
import androidx.media3.common.text.CueGroup;
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector;
import androidx.media3.exoplayer.trackselection.MappingTrackSelector;
import androidx.media3.ui.AspectRatioFrameLayout;
import androidx.media3.ui.CaptionStyleCompat;
import androidx.media3.ui.SubtitleView;
import androidx.media3.exoplayer.upstream.DefaultBandwidthMeter;
import androidx.media3.common.util.Util;
import androidx.media3.common.VideoSize;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
Expand Down Expand Up @@ -794,7 +795,7 @@ public void handleIntent(@NonNull final Intent intent) {
// Player can have state = IDLE when playback is stopped or failed
// and we should retry in this case
if (simpleExoPlayer.getPlaybackState()
== com.google.android.exoplayer2.Player.STATE_IDLE) {
== androidx.media3.common.Player.STATE_IDLE) {
simpleExoPlayer.prepare();
}
if (shouldSeek()) {
Expand All @@ -811,7 +812,7 @@ public void handleIntent(@NonNull final Intent intent) {
// Player can have state = IDLE when playback is stopped or failed
// and we should retry in this case
if (simpleExoPlayer.getPlaybackState()
== com.google.android.exoplayer2.Player.STATE_IDLE) {
== androidx.media3.common.Player.STATE_IDLE) {
simpleExoPlayer.prepare();
}
simpleExoPlayer.setPlayWhenReady(playWhenReady);
Expand Down Expand Up @@ -2265,7 +2266,7 @@ public void onPlayWhenReadyChanged(final boolean playWhenReady, final int reason
+ "reason = [" + reason + "]");
}
final int playbackState = exoPlayerIsNull()
? com.google.android.exoplayer2.Player.STATE_IDLE
? androidx.media3.common.Player.STATE_IDLE
: simpleExoPlayer.getPlaybackState();
updatePlaybackState(playWhenReady, playbackState);
}
Expand Down Expand Up @@ -2294,22 +2295,22 @@ private void updatePlaybackState(final boolean playWhenReady, final int playback
}

switch (playbackState) {
case com.google.android.exoplayer2.Player.STATE_IDLE: // 1
case androidx.media3.common.Player.STATE_IDLE: // 1
isPrepared = false;
break;
case com.google.android.exoplayer2.Player.STATE_BUFFERING: // 2
case androidx.media3.common.Player.STATE_BUFFERING: // 2
if (isPrepared) {
changeState(STATE_BUFFERING);
}
break;
case com.google.android.exoplayer2.Player.STATE_READY: //3
case androidx.media3.common.Player.STATE_READY: //3
if (!isPrepared) {
isPrepared = true;
onPrepared(playWhenReady);
}
changeState(playWhenReady ? STATE_PLAYING : STATE_PAUSED);
break;
case com.google.android.exoplayer2.Player.STATE_ENDED: // 4
case androidx.media3.common.Player.STATE_ENDED: // 4
changeState(STATE_COMPLETED);
saveStreamProgressStateCompleted();
isPrepared = false;
Expand Down Expand Up @@ -2826,13 +2827,13 @@ private void setRepeatModeButton(final AppCompatImageButton imageButton,
@RepeatMode final int repeatMode) {
switch (repeatMode) {
case REPEAT_MODE_OFF:
imageButton.setImageResource(R.drawable.exo_controls_repeat_off);
imageButton.setImageResource(R.drawable.exo_icon_repeat_off);
break;
case REPEAT_MODE_ONE:
imageButton.setImageResource(R.drawable.exo_controls_repeat_one);
imageButton.setImageResource(R.drawable.exo_icon_repeat_one);
break;
case REPEAT_MODE_ALL:
imageButton.setImageResource(R.drawable.exo_controls_repeat_all);
imageButton.setImageResource(R.drawable.exo_icon_repeat_all);
break;
}
}
Expand Down Expand Up @@ -2920,13 +2921,13 @@ public void onScreenRotationButtonClicked() {
* This is done because not all source resolution errors are {@link PlaybackException}, which
* are also captured by {@link ExoPlayer} and stops the playback.</p>
*
* @param player The {@link com.google.android.exoplayer2.Player} whose state changed.
* @param events The {@link com.google.android.exoplayer2.Player.Events} that has triggered
* @param player The {@link androidx.media3.common.Player} whose state changed.
* @param events The {@link androidx.media3.common.Player.Events} that has triggered
* the player state changes.
**/
@Override
public void onEvents(@NonNull final com.google.android.exoplayer2.Player player,
@NonNull final com.google.android.exoplayer2.Player.Events events) {
public void onEvents(@NonNull final androidx.media3.common.Player player,
@NonNull final androidx.media3.common.Player.Events events) {
Listener.super.onEvents(player, events);
MediaItemTag.from(player.getCurrentMediaItem()).ifPresent(tag -> {
if (tag == currentMetadata) {
Expand Down Expand Up @@ -3053,7 +3054,7 @@ public void onPrepare() {
//region Errors

/**
* Process exceptions produced by {@link com.google.android.exoplayer2.ExoPlayer ExoPlayer}.
* Process exceptions produced by {@link androidx.media3.exoplayer.ExoPlayer ExoPlayer}.
* <p>There are multiple types of errors:</p>
* <ul>
* <li>{@link PlaybackException#ERROR_CODE_BEHIND_LIVE_WINDOW BEHIND_LIVE_WINDOW}:
Expand All @@ -3078,7 +3079,7 @@ public void onPrepare() {
* For any error above that is <b>not</b> explicitly <b>catchable</b>, the player will
* create a notification so users are aware.
* </ul>
* @see com.google.android.exoplayer2.Player.Listener#onPlayerError(PlaybackException)
* @see androidx.media3.common.Player.Listener#onPlayerError(PlaybackException)
* */
// Any error code not explicitly covered here are either unrelated to NewPipe use case
// (e.g. DRM) or not recoverable (e.g. Decoder error). In both cases, the player should
Expand Down
Loading