mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-03-13 15:20:26 +08:00
SponsorBlock: don't skip short segments option
This commit is contained in:
@@ -20,7 +20,6 @@ import com.liskovsoft.smartyoutubetv2.common.app.presenters.AppDialogPresenter;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.presenters.settings.SponsorBlockSettingsPresenter;
|
||||
import com.liskovsoft.smartyoutubetv2.common.prefs.SponsorBlockData;
|
||||
import com.liskovsoft.sharedutils.rx.RxHelper;
|
||||
import com.liskovsoft.smartyoutubetv2.common.prefs.PlayerTweaksData;
|
||||
import com.liskovsoft.smartyoutubetv2.common.utils.Utils;
|
||||
import com.liskovsoft.youtubeapi.service.YouTubeServiceManager;
|
||||
import io.reactivex.Observable;
|
||||
@@ -369,7 +368,7 @@ public class SponsorBlockController extends BasePlayerController {
|
||||
}
|
||||
|
||||
private void applyActions(List<SponsorSegment> foundSegments) {
|
||||
if (foundSegments == null) {
|
||||
if (getPlayer() == null || foundSegments == null) {
|
||||
mLastSkipPosMs = 0;
|
||||
return;
|
||||
}
|
||||
@@ -384,7 +383,7 @@ public class SponsorBlockController extends BasePlayerController {
|
||||
long skipPosMs = lastSegment.getEndMs();
|
||||
// Fix infinite skip loop by ignoring short segments. TextureView has a seek bug.
|
||||
long skipDurationMs = Math.min(skipPosMs, getPlayer().getDurationMs()) - getPlayer().getPositionMs();
|
||||
boolean stayQuiet = skipDurationMs < 10_000 && PlayerTweaksData.instance(getContext()).isTextureViewEnabled();
|
||||
boolean stayQuiet = skipDurationMs < 10_000 && (getPlayerTweaksData().isTextureViewEnabled() || getSponsorBlockData().isStayQuietEnabled());
|
||||
|
||||
if (!stayQuiet) {
|
||||
if (type == SponsorBlockData.ACTION_SKIP_ONLY || getPlayer().isInPIPMode() || Utils.isScreenOff(getContext()) || isEmbedPlayer()) {
|
||||
|
||||
@@ -62,7 +62,7 @@ public class SponsorBlockSettingsPresenter extends BasePresenter<Void> {
|
||||
|
||||
OptionItem sponsorBlockOption = UiOptionItem.from(getContext().getString(R.string.enable),
|
||||
option -> {
|
||||
mContentBlockData.enableSponsorBlock(option.isSelected());
|
||||
mContentBlockData.setSponsorBlockEnabled(option.isSelected());
|
||||
SponsorBlockData.instance(getContext()).stopExcludingChannel(channelId);
|
||||
},
|
||||
!isChannelExcluded && mContentBlockData.isSponsorBlockEnabled()
|
||||
@@ -138,12 +138,16 @@ public class SponsorBlockSettingsPresenter extends BasePresenter<Void> {
|
||||
private void appendMiscSection(AppDialogPresenter settingsPresenter) {
|
||||
List<OptionItem> options = new ArrayList<>();
|
||||
|
||||
options.add(UiOptionItem.from(getContext().getString(R.string.dont_skip_short_segements),
|
||||
optionItem -> mContentBlockData.setStayQuietEnabled(optionItem.isSelected()),
|
||||
mContentBlockData.isStayQuietEnabled()));
|
||||
|
||||
options.add(UiOptionItem.from(getContext().getString(R.string.paid_content_notification),
|
||||
optionItem -> mContentBlockData.enablePaidContentNotification(optionItem.isSelected()),
|
||||
optionItem -> mContentBlockData.setPaidContentNotificationEnabled(optionItem.isSelected()),
|
||||
mContentBlockData.isPaidContentNotificationEnabled()));
|
||||
|
||||
options.add(UiOptionItem.from(getContext().getString(R.string.skip_each_segment_once),
|
||||
optionItem -> mContentBlockData.enableDontSkipSegmentAgain(optionItem.isSelected()),
|
||||
optionItem -> mContentBlockData.setDontSkipSegmentAgainEnabled(optionItem.isSelected()),
|
||||
mContentBlockData.isDontSkipSegmentAgainEnabled()));
|
||||
|
||||
options.add(UiOptionItem.from(getContext().getString(R.string.content_block_alt_server),
|
||||
|
||||
@@ -33,6 +33,7 @@ public class SponsorBlockData {
|
||||
private final Set<String> mExcludedChannels = new LinkedHashSet<>();
|
||||
private boolean mIsDontSkipSegmentAgainEnabled;
|
||||
private boolean mIsPaidContentNotificationEnabled;
|
||||
private boolean mIsStayQuietEnabled;
|
||||
private Map<String, Integer> mSegmentLocalizedMapping;
|
||||
private Map<String, Integer> mSegmentColorMapping;
|
||||
private Set<String> mAllCategories;
|
||||
@@ -191,7 +192,7 @@ public class SponsorBlockData {
|
||||
return mIsSponsorBlockEnabled;
|
||||
}
|
||||
|
||||
public void enableSponsorBlock(boolean enabled) {
|
||||
public void setSponsorBlockEnabled(boolean enabled) {
|
||||
mIsSponsorBlockEnabled = enabled;
|
||||
persistState();
|
||||
}
|
||||
@@ -210,7 +211,7 @@ public class SponsorBlockData {
|
||||
return mIsDontSkipSegmentAgainEnabled;
|
||||
}
|
||||
|
||||
public void enableDontSkipSegmentAgain(boolean enabled) {
|
||||
public void setDontSkipSegmentAgainEnabled(boolean enabled) {
|
||||
mIsDontSkipSegmentAgainEnabled = enabled;
|
||||
persistState();
|
||||
}
|
||||
@@ -219,11 +220,20 @@ public class SponsorBlockData {
|
||||
return mIsPaidContentNotificationEnabled;
|
||||
}
|
||||
|
||||
public void enablePaidContentNotification(boolean enabled) {
|
||||
public void setPaidContentNotificationEnabled(boolean enabled) {
|
||||
mIsPaidContentNotificationEnabled = enabled;
|
||||
persistState();
|
||||
}
|
||||
|
||||
public boolean isStayQuietEnabled() {
|
||||
return mIsStayQuietEnabled;
|
||||
}
|
||||
|
||||
public void setStayQuietEnabled(boolean enable) {
|
||||
mIsStayQuietEnabled = enable;
|
||||
persistState();
|
||||
}
|
||||
|
||||
public boolean isAltServerEnabled() {
|
||||
return GlobalPreferences.instance(mAppPrefs.getContext()).isContentBlockAltServerEnabled();
|
||||
}
|
||||
@@ -246,6 +256,7 @@ public class SponsorBlockData {
|
||||
mIsDontSkipSegmentAgainEnabled = Helpers.parseBoolean(split, 8, false);
|
||||
String excludedChannels = Helpers.parseStr(split, 9);
|
||||
mIsPaidContentNotificationEnabled = Helpers.parseBoolean(split, 10, false);
|
||||
mIsStayQuietEnabled = Helpers.parseBoolean(split, 11, true);
|
||||
|
||||
if (colorCategories != null) {
|
||||
String[] categoriesArr = Helpers.splitArray(colorCategories);
|
||||
@@ -301,7 +312,7 @@ public class SponsorBlockData {
|
||||
mAppPrefs.setData(SPONSOR_BLOCK_DATA, Helpers.mergeData(
|
||||
mIsSponsorBlockEnabled, null, null, null,
|
||||
null, null, actions, colorCategories, mIsDontSkipSegmentAgainEnabled,
|
||||
excludedChannels, mIsPaidContentNotificationEnabled
|
||||
excludedChannels, mIsPaidContentNotificationEnabled, mIsStayQuietEnabled
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -722,4 +722,5 @@
|
||||
<string name="player_time_stretching">Растяжение аудио во времени</string>
|
||||
<string name="player_time_stretching_desc">Сохраняет естественное звучание голоса при изменении скорости. Может значительно снизить производительность на некоторых устройствах.</string>
|
||||
<string name="queue_respects_playback_mode">Очередь учитывает режим воспроизведения</string>
|
||||
<string name="dont_skip_short_segements">Не пропускать короткие сегменты (< 10 сек)</string>
|
||||
</resources>
|
||||
|
||||
@@ -732,4 +732,5 @@
|
||||
<string name="player_time_stretching">Ses zaman esnetme</string>
|
||||
<string name="player_time_stretching_desc">Hız değiştirildiğinde sesi doğal tutar. Bazı cihazlarda performansı önemli ölçüde düşürebilir.</string>
|
||||
<string name="queue_respects_playback_mode">Kuyruk oynatma modunu dikkate alır</string>
|
||||
<string name="dont_skip_short_segements">Kısa bölümleri atlama (< 10 sn)</string>
|
||||
</resources>
|
||||
|
||||
@@ -720,4 +720,5 @@
|
||||
<string name="player_time_stretching">Розтягування аудіо в часі</string>
|
||||
<string name="player_time_stretching_desc">Зберігає природний голос при зміні швидкості. Може суттєво знизити продуктивність на деяких пристроях.</string>
|
||||
<string name="queue_respects_playback_mode">Черга враховує режим відтворення</string>
|
||||
<string name="dont_skip_short_segements">Не пропускати короткі сегменти (< 10 с)</string>
|
||||
</resources>
|
||||
|
||||
@@ -732,4 +732,5 @@
|
||||
<string name="player_time_stretching">Audio time stretching</string>
|
||||
<string name="player_time_stretching_desc">Keeps voice natural when changing speed. May significantly reduce performance on some devices.</string>
|
||||
<string name="queue_respects_playback_mode">Queue respects playback mode</string>
|
||||
<string name="dont_skip_short_segements">Don\'t skip short segments (< 10sec)</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user