From a163d5461d20f722cc21a9b47180bb74b10a012e Mon Sep 17 00:00:00 2001 From: TobiGr Date: Tue, 21 Dec 2021 00:18:58 +0100 Subject: [PATCH 1/6] Make PlayerHolder.bound private --- .../newpipe/fragments/detail/VideoDetailFragment.java | 4 ++-- .../java/org/schabi/newpipe/player/helper/PlayerHolder.java | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 6a956c6dc..a5e590ba0 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -685,7 +685,7 @@ public final class VideoDetailFragment }); setupBottomPlayer(); - if (!playerHolder.bound) { + if (!playerHolder.isBound()) { setHeightThumbnail(); } else { playerHolder.startService(false, this); @@ -1434,7 +1434,7 @@ public final class VideoDetailFragment bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } // Rebound to the service if it was closed via notification or mini player - if (!playerHolder.bound) { + if (!playerHolder.isBound()) { playerHolder.startService( false, VideoDetailFragment.this); } diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java index 46239cab1..3d960ae90 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java @@ -41,7 +41,7 @@ public final class PlayerHolder { private PlayerServiceExtendedEventListener listener; private final PlayerServiceConnection serviceConnection = new PlayerServiceConnection(); - public boolean bound; + private boolean bound; private MainPlayer playerService; private Player player; @@ -70,6 +70,10 @@ public final class PlayerHolder { return player != null; } + public boolean isBound() { + return bound; + } + public int getQueueSize() { return isPlayerOpen() ? player.getPlayQueue().size() : 0; } From d71af9a625db22a6e8edc8b9c78e01d5aa7d0ff0 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Tue, 21 Dec 2021 20:53:17 +0100 Subject: [PATCH 2/6] Introduce constants for some Strings that indicate no data in Tab class --- .../org/schabi/newpipe/settings/tabs/Tab.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java index eac5ce311..aa03bbfa6 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java +++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java @@ -36,6 +36,10 @@ import java.util.Objects; public abstract class Tab { private static final String JSON_TAB_ID_KEY = "tab_id"; + private static final String NO_NAME = ""; + private static final String NO_ID = ""; + private static final String NO_URL = ""; + Tab() { } @@ -185,7 +189,9 @@ public abstract class Tab { @Override public String getTabName(final Context context) { - return "NewPipe"; //context.getString(R.string.blank_page_summary); + // TODO: find a better name for the blank tab (maybe "blank_tab") or replace it with + // context.getString(R.string.app_name); + return "NewPipe"; // context.getString(R.string.blank_page_summary); } @DrawableRes @@ -309,7 +315,7 @@ public abstract class Tab { private String kioskId; private KioskTab() { - this(-1, ""); + this(-1, NO_ID); } public KioskTab(final int kioskServiceId, final String kioskId) { @@ -357,7 +363,7 @@ public abstract class Tab { @Override protected void readDataFromJson(final JsonObject jsonObject) { kioskServiceId = jsonObject.getInt(JSON_KIOSK_SERVICE_ID_KEY, -1); - kioskId = jsonObject.getString(JSON_KIOSK_ID_KEY, ""); + kioskId = jsonObject.getString(JSON_KIOSK_ID_KEY, NO_ID); } @Override @@ -395,7 +401,7 @@ public abstract class Tab { private String channelName; private ChannelTab() { - this(-1, "", ""); + this(-1, NO_URL, NO_NAME); } public ChannelTab(final int channelServiceId, final String channelUrl, @@ -440,8 +446,8 @@ public abstract class Tab { @Override protected void readDataFromJson(final JsonObject jsonObject) { channelServiceId = jsonObject.getInt(JSON_CHANNEL_SERVICE_ID_KEY, -1); - channelUrl = jsonObject.getString(JSON_CHANNEL_URL_KEY, ""); - channelName = jsonObject.getString(JSON_CHANNEL_NAME_KEY, ""); + channelUrl = jsonObject.getString(JSON_CHANNEL_URL_KEY, NO_URL); + channelName = jsonObject.getString(JSON_CHANNEL_NAME_KEY, NO_NAME); } @Override @@ -527,7 +533,7 @@ public abstract class Tab { private LocalItemType playlistType; private PlaylistTab() { - this(-1, ""); + this(-1, NO_NAME); } public PlaylistTab(final long playlistId, final String playlistName) { @@ -535,7 +541,7 @@ public abstract class Tab { this.playlistId = playlistId; this.playlistType = LocalItemType.PLAYLIST_LOCAL_ITEM; this.playlistServiceId = -1; - this.playlistUrl = ""; + this.playlistUrl = NO_URL; } public PlaylistTab(final int playlistServiceId, final String playlistUrl, @@ -589,8 +595,8 @@ public abstract class Tab { @Override protected void readDataFromJson(final JsonObject jsonObject) { playlistServiceId = jsonObject.getInt(JSON_PLAYLIST_SERVICE_ID_KEY, -1); - playlistUrl = jsonObject.getString(JSON_PLAYLIST_URL_KEY, ""); - playlistName = jsonObject.getString(JSON_PLAYLIST_NAME_KEY, ""); + playlistUrl = jsonObject.getString(JSON_PLAYLIST_URL_KEY, NO_URL); + playlistName = jsonObject.getString(JSON_PLAYLIST_NAME_KEY, NO_NAME); playlistId = jsonObject.getInt(JSON_PLAYLIST_ID_KEY, -1); playlistType = LocalItemType.valueOf( jsonObject.getString(JSON_PLAYLIST_TYPE_KEY, From 37b8a9375f58770d59f9ce16d72eee476aa5ee49 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Tue, 21 Dec 2021 20:54:06 +0100 Subject: [PATCH 3/6] Small improvements to code quality and readability Add annotations to methods and parameters. Replace Jetbrains' @NotNull with Androidx' @NonNull annotatiation. Make class variables static if possible. Use constants for some Strings. Simplify if conditions. --- .../material/appbar/FlingBehavior.java | 1 + .../fragments/list/search/SearchFragment.java | 2 +- .../local/subscription/item/ChannelItem.kt | 8 ++--- .../org/schabi/newpipe/player/Player.java | 26 +++++++------- .../player/event/PlayerGestureListener.java | 34 +++++++++---------- .../newpipe/player/helper/PlayerHolder.java | 6 ++-- .../settings/BasePreferenceFragment.java | 2 +- .../us/shandian/giga/io/FileStreamSAF.java | 4 +++ 8 files changed, 44 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java b/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java index ca1bd79d2..3e5f408f7 100644 --- a/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java +++ b/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java @@ -63,6 +63,7 @@ public final class FlingBehavior extends AppBarLayout.Behavior { return consumed == dy; } + @Override public boolean onInterceptTouchEvent(@NonNull final CoordinatorLayout parent, @NonNull final AppBarLayout child, @NonNull final MotionEvent ev) { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 098df760d..15424334d 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -724,7 +724,7 @@ public class SearchFragment extends BaseListFragment 0 + && !infoListAdapter.getItemsList().isEmpty() && !isLoading.get()) { hideSuggestionsPanel(); hideKeyboardSearch(); diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/item/ChannelItem.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/item/ChannelItem.kt index 2b964779c..a8c05838f 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/item/ChannelItem.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/item/ChannelItem.kt @@ -54,11 +54,9 @@ class ChannelItem( context.getString(R.string.subscribers_count_not_available) } - if (itemVersion == ItemVersion.NORMAL) { - if (infoItem.streamCount >= 0) { - val formattedVideoAmount = Localization.localizeStreamCount(context, infoItem.streamCount) - details = Localization.concatenateStrings(details, formattedVideoAmount) - } + if (itemVersion == ItemVersion.NORMAL && infoItem.streamCount >= 0) { + val formattedVideoAmount = Localization.localizeStreamCount(context, infoItem.streamCount) + details = Localization.concatenateStrings(details, formattedVideoAmount) } return details } diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index ee09cb866..c038f5573 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -2348,7 +2348,8 @@ public final class Player implements NotificationUtil.getInstance().createNotificationIfNeededAndUpdate(this, false); } - private void setRepeatModeButton(final AppCompatImageButton imageButton, final int repeatMode) { + private void setRepeatModeButton(final AppCompatImageButton imageButton, + @RepeatMode final int repeatMode) { switch (repeatMode) { case REPEAT_MODE_OFF: imageButton.setImageResource(R.drawable.exo_controls_repeat_off); @@ -2362,7 +2363,7 @@ public final class Player implements } } - private void setShuffleButton(final ImageButton button, final boolean shuffled) { + private void setShuffleButton(@NonNull final ImageButton button, final boolean shuffled) { button.setImageAlpha(shuffled ? 255 : 77); } //endregion @@ -2387,7 +2388,7 @@ public final class Player implements return !exoPlayerIsNull() && simpleExoPlayer.getVolume() == 0; } - private void setMuteButton(final ImageButton button, final boolean isMuted) { + private void setMuteButton(@NonNull final ImageButton button, final boolean isMuted) { button.setImageDrawable(AppCompatResources.getDrawable(context, isMuted ? R.drawable.ic_volume_off : R.drawable.ic_volume_up)); } @@ -2876,7 +2877,7 @@ public final class Player implements databaseUpdateDisposable .add(recordManager.saveStreamState(currentMetadata.getMetadata(), progressMillis) .observeOn(AndroidSchedulers.mainThread()) - .doOnError((e) -> { + .doOnError(e -> { if (DEBUG) { e.printStackTrace(); } @@ -3386,7 +3387,7 @@ public final class Player implements playbackSpeedPopupMenu.setOnDismissListener(this); } - private void buildCaptionMenu(final List availableLanguages) { + private void buildCaptionMenu(@NonNull final List availableLanguages) { if (captionPopupMenu == null) { return; } @@ -3454,7 +3455,7 @@ public final class Player implements * Called when an item of the quality selector or the playback speed selector is selected. */ @Override - public boolean onMenuItemClick(final MenuItem menuItem) { + public boolean onMenuItemClick(@NonNull final MenuItem menuItem) { if (DEBUG) { Log.d(TAG, "onMenuItemClick() called with: " + "menuItem = [" + menuItem + "], " @@ -3491,7 +3492,7 @@ public final class Player implements * Called when some popup menu is dismissed. */ @Override - public void onDismiss(final PopupMenu menu) { + public void onDismiss(@Nullable final PopupMenu menu) { if (DEBUG) { Log.d(TAG, "onDismiss() called with: menu = [" + menu + "]"); } @@ -3544,7 +3545,7 @@ public final class Player implements isSomePopupMenuVisible = true; } - private void setPlaybackQuality(final String quality) { + private void setPlaybackQuality(@Nullable final String quality) { videoResolver.setPlaybackQuality(quality); } //endregion @@ -3568,7 +3569,7 @@ public final class Player implements final int minimumLength = Math.min(metrics.heightPixels, metrics.widthPixels); final float captionRatioInverse = 20f + 4f * (1.0f - captionScale); binding.subtitleView.setFixedTextSize( - TypedValue.COMPLEX_UNIT_PX, (float) minimumLength / captionRatioInverse); + TypedValue.COMPLEX_UNIT_PX, minimumLength / captionRatioInverse); } binding.subtitleView.setApplyEmbeddedStyles(captionStyle == CaptionStyleCompat.DEFAULT); binding.subtitleView.setStyle(captionStyle); @@ -3845,7 +3846,7 @@ public final class Player implements } @Override // exoplayer listener - public void onVideoSizeChanged(final VideoSize videoSize) { + public void onVideoSizeChanged(@NonNull final VideoSize videoSize) { if (DEBUG) { Log.d(TAG, "onVideoSizeChanged() called with: " + "width / height = [" + videoSize.width + " / " + videoSize.height @@ -3959,7 +3960,7 @@ public final class Player implements } } - private int distanceFromCloseButton(final MotionEvent popupMotionEvent) { + private int distanceFromCloseButton(@NonNull final MotionEvent popupMotionEvent) { final int closeOverlayButtonX = closeOverlayBinding.closeButton.getLeft() + closeOverlayBinding.closeButton.getWidth() / 2; final int closeOverlayButtonY = closeOverlayBinding.closeButton.getTop() @@ -3978,7 +3979,7 @@ public final class Player implements return buttonRadius * 1.2f; } - public boolean isInsideClosingRadius(final MotionEvent popupMotionEvent) { + public boolean isInsideClosingRadius(@NonNull final MotionEvent popupMotionEvent) { return distanceFromCloseButton(popupMotionEvent) <= getClosingRadius(); } //endregion @@ -4098,6 +4099,7 @@ public final class Player implements } } + @Nullable public AppCompatActivity getParentActivity() { // ! instanceof ViewGroup means that view was added via windowManager for Popup if (binding == null || !(binding.getRoot().getParent() instanceof ViewGroup)) { diff --git a/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java b/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java index e55c596b8..25ace1c05 100644 --- a/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java +++ b/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java @@ -1,5 +1,12 @@ package org.schabi.newpipe.player.event; +import static org.schabi.newpipe.ktx.AnimationType.ALPHA; +import static org.schabi.newpipe.ktx.AnimationType.SCALE_AND_ALPHA; +import static org.schabi.newpipe.ktx.ViewUtils.animate; +import static org.schabi.newpipe.player.Player.DEFAULT_CONTROLS_DURATION; +import static org.schabi.newpipe.player.Player.DEFAULT_CONTROLS_HIDE_TIME; +import static org.schabi.newpipe.player.Player.STATE_PLAYING; + import android.app.Activity; import android.util.Log; import android.view.MotionEvent; @@ -8,22 +15,15 @@ import android.view.Window; import android.view.WindowManager; import android.widget.ProgressBar; +import androidx.annotation.NonNull; import androidx.appcompat.content.res.AppCompatResources; -import org.jetbrains.annotations.NotNull; import org.schabi.newpipe.MainActivity; import org.schabi.newpipe.R; import org.schabi.newpipe.player.MainPlayer; import org.schabi.newpipe.player.Player; import org.schabi.newpipe.player.helper.PlayerHelper; -import static org.schabi.newpipe.ktx.AnimationType.ALPHA; -import static org.schabi.newpipe.ktx.AnimationType.SCALE_AND_ALPHA; -import static org.schabi.newpipe.ktx.ViewUtils.animate; -import static org.schabi.newpipe.player.Player.DEFAULT_CONTROLS_DURATION; -import static org.schabi.newpipe.player.Player.DEFAULT_CONTROLS_HIDE_TIME; -import static org.schabi.newpipe.player.Player.STATE_PLAYING; - /** * GestureListener for the player * @@ -45,8 +45,8 @@ public class PlayerGestureListener } @Override - public void onDoubleTap(@NotNull final MotionEvent event, - @NotNull final DisplayPortion portion) { + public void onDoubleTap(@NonNull final MotionEvent event, + @NonNull final DisplayPortion portion) { if (DEBUG) { Log.d(TAG, "onDoubleTap called with playerType = [" + player.getPlayerType() + "], portion = [" + portion + "]"); @@ -65,7 +65,7 @@ public class PlayerGestureListener } @Override - public void onSingleTap(@NotNull final MainPlayer.PlayerType playerType) { + public void onSingleTap(@NonNull final MainPlayer.PlayerType playerType) { if (DEBUG) { Log.d(TAG, "onSingleTap called with playerType = [" + player.getPlayerType() + "]"); } @@ -85,10 +85,10 @@ public class PlayerGestureListener } @Override - public void onScroll(@NotNull final MainPlayer.PlayerType playerType, - @NotNull final DisplayPortion portion, - @NotNull final MotionEvent initialEvent, - @NotNull final MotionEvent movingEvent, + public void onScroll(@NonNull final MainPlayer.PlayerType playerType, + @NonNull final DisplayPortion portion, + @NonNull final MotionEvent initialEvent, + @NonNull final MotionEvent movingEvent, final float distanceX, final float distanceY) { if (DEBUG) { Log.d(TAG, "onScroll called with playerType = [" @@ -197,8 +197,8 @@ public class PlayerGestureListener } @Override - public void onScrollEnd(@NotNull final MainPlayer.PlayerType playerType, - @NotNull final MotionEvent event) { + public void onScrollEnd(@NonNull final MainPlayer.PlayerType playerType, + @NonNull final MotionEvent event) { if (DEBUG) { Log.d(TAG, "onScrollEnd called with playerType = [" + player.getPlayerType() + "]"); diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java index 3d960ae90..10e315667 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java @@ -35,8 +35,8 @@ public final class PlayerHolder { return PlayerHolder.instance; } - private final boolean DEBUG = MainActivity.DEBUG; - private final String TAG = PlayerHolder.class.getSimpleName(); + private static final boolean DEBUG = MainActivity.DEBUG; + private static final String TAG = PlayerHolder.class.getSimpleName(); private PlayerServiceExtendedEventListener listener; @@ -152,7 +152,7 @@ public final class PlayerHolder { } startPlayerListener(); } - }; + } private void bind(final Context context) { if (DEBUG) { diff --git a/app/src/main/java/org/schabi/newpipe/settings/BasePreferenceFragment.java b/app/src/main/java/org/schabi/newpipe/settings/BasePreferenceFragment.java index 8b2bd9c9a..a745861ad 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/BasePreferenceFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/BasePreferenceFragment.java @@ -18,7 +18,7 @@ import java.util.Objects; public abstract class BasePreferenceFragment extends PreferenceFragmentCompat { protected final String TAG = getClass().getSimpleName() + "@" + Integer.toHexString(hashCode()); - protected final boolean DEBUG = MainActivity.DEBUG; + protected static final boolean DEBUG = MainActivity.DEBUG; SharedPreferences defaultPreferences; diff --git a/app/src/main/java/us/shandian/giga/io/FileStreamSAF.java b/app/src/main/java/us/shandian/giga/io/FileStreamSAF.java index 000900918..b7dd0a103 100644 --- a/app/src/main/java/us/shandian/giga/io/FileStreamSAF.java +++ b/app/src/main/java/us/shandian/giga/io/FileStreamSAF.java @@ -108,10 +108,12 @@ public class FileStreamSAF extends SharpStream { return true; } + @Override public boolean canSetLength() { return true; } + @Override public boolean canSeek() { return true; } @@ -131,10 +133,12 @@ public class FileStreamSAF extends SharpStream { out.write(buffer, offset, count); } + @Override public void setLength(long length) throws IOException { channel.truncate(length); } + @Override public void seek(long offset) throws IOException { channel.position(offset); } From c90237c14ceaffe16d27d9a9faec3156bef760f7 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sun, 19 Dec 2021 20:16:10 +0100 Subject: [PATCH 4/6] Removed/Reverted MediaParser support (Android 11+) due to bugs --- .../player/helper/PlayerDataSource.java | 51 +++---------------- 1 file changed, 8 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java index b7584151d..708b72ff2 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java @@ -1,18 +1,14 @@ package org.schabi.newpipe.player.helper; import android.content.Context; -import android.os.Build; import androidx.annotation.NonNull; -import com.google.android.exoplayer2.source.MediaParserExtractorAdapter; import com.google.android.exoplayer2.source.ProgressiveMediaSource; import com.google.android.exoplayer2.source.SingleSampleMediaSource; -import com.google.android.exoplayer2.source.chunk.MediaParserChunkExtractor; import com.google.android.exoplayer2.source.dash.DashMediaSource; import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource; import com.google.android.exoplayer2.source.hls.HlsMediaSource; -import com.google.android.exoplayer2.source.hls.MediaParserHlsMediaChunkExtractor; import com.google.android.exoplayer2.source.smoothstreaming.DefaultSsChunkSource; import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource; import com.google.android.exoplayer2.upstream.DataSource; @@ -46,17 +42,10 @@ public class PlayerDataSource { } public HlsMediaSource.Factory getLiveHlsMediaSourceFactory() { - final HlsMediaSource.Factory factory = - new HlsMediaSource.Factory(cachelessDataSourceFactory) - .setAllowChunklessPreparation(true) - .setLoadErrorHandlingPolicy( - new DefaultLoadErrorHandlingPolicy(MANIFEST_MINIMUM_RETRY)); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - factory.setExtractorFactory(MediaParserHlsMediaChunkExtractor.FACTORY); - } - - return factory; + return new HlsMediaSource.Factory(cachelessDataSourceFactory) + .setAllowChunklessPreparation(true) + .setLoadErrorHandlingPolicy( + new DefaultLoadErrorHandlingPolicy(MANIFEST_MINIMUM_RETRY)); } public DashMediaSource.Factory getLiveDashMediaSourceFactory() { @@ -71,26 +60,11 @@ public class PlayerDataSource { private DefaultDashChunkSource.Factory getDefaultDashChunkSourceFactory( final DataSource.Factory dataSourceFactory ) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - return new DefaultDashChunkSource.Factory( - MediaParserChunkExtractor.FACTORY, - dataSourceFactory, - 1 - ); - } - return new DefaultDashChunkSource.Factory(dataSourceFactory); } public HlsMediaSource.Factory getHlsMediaSourceFactory() { - final HlsMediaSource.Factory factory = new HlsMediaSource.Factory(cacheDataSourceFactory); - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { - return factory; - } - - // *** >= Android 11 / R / API 30 *** - return factory.setExtractorFactory(MediaParserHlsMediaChunkExtractor.FACTORY); + return new HlsMediaSource.Factory(cacheDataSourceFactory); } public DashMediaSource.Factory getDashMediaSourceFactory() { @@ -101,18 +75,9 @@ public class PlayerDataSource { } public ProgressiveMediaSource.Factory getExtractorMediaSourceFactory() { - final ProgressiveMediaSource.Factory factory; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - factory = new ProgressiveMediaSource.Factory( - cacheDataSourceFactory, - MediaParserExtractorAdapter.FACTORY - ); - } else { - factory = new ProgressiveMediaSource.Factory(cacheDataSourceFactory); - } - - return factory.setLoadErrorHandlingPolicy( - new DefaultLoadErrorHandlingPolicy(EXTRACTOR_MINIMUM_RETRY)); + return new ProgressiveMediaSource.Factory(cacheDataSourceFactory) + .setLoadErrorHandlingPolicy( + new DefaultLoadErrorHandlingPolicy(EXTRACTOR_MINIMUM_RETRY)); } public SingleSampleMediaSource.Factory getSampleMediaSourceFactory() { From 8c6e37d1d13d94e377d4826aa2756d8897948c9e Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 4 Dec 2021 22:23:09 +0100 Subject: [PATCH 5/6] Disable media tunneling on Philips QM16XE --- app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java b/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java index bbe9a7edb..a4ff5ff19 100644 --- a/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java @@ -37,6 +37,9 @@ public final class DeviceUtils { // Hilife TV private static final boolean REALTEKATV = Build.VERSION.SDK_INT == 25 && Build.DEVICE.equals("RealtekATV"); + // Philips QM16XE + private static final boolean QM16XE_U = Build.VERSION.SDK_INT == 23 + && Build.DEVICE.equals("QM16XE_U"); private DeviceUtils() { } @@ -134,7 +137,8 @@ public final class DeviceUtils { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !HI3798MV200 && !CVT_MT5886_EU_1G - && !REALTEKATV; + && !REALTEKATV + && !QM16XE_U; } public static boolean isLandscape(final Context context) { From ff8868f6a3de2f8885c0a02fb906c9f98c186144 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Thu, 23 Dec 2021 23:41:20 +0100 Subject: [PATCH 6/6] NewPipe version 0.21.15 (981) --- app/build.gradle | 4 ++-- fastlane/metadata/android/en-US/changelogs/981.txt | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/981.txt diff --git a/app/build.gradle b/app/build.gradle index 35bdd998e..0f7c28a43 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,8 +17,8 @@ android { resValue "string", "app_name", "NewPipe" minSdkVersion 19 targetSdkVersion 29 - versionCode 980 - versionName "0.21.14" + versionCode 981 + versionName "0.21.15" multiDexEnabled true diff --git a/fastlane/metadata/android/en-US/changelogs/981.txt b/fastlane/metadata/android/en-US/changelogs/981.txt new file mode 100644 index 000000000..9a2230ade --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/981.txt @@ -0,0 +1,2 @@ +Removed MediaParser support to fix failing playback resume after buffering on Android 11+. +Disabled media tunneling on Philips QM16XE to fix playback problems.