Add skipping last episode minus the episode

Needs to determine if the current episode is the last episode, but this fills in all the UI and config
This commit is contained in:
TwistedUmbrellaX 2024-10-08 08:02:28 -04:00
parent 93f0bee301
commit ad186140bd
3 changed files with 29 additions and 2 deletions

View File

@ -163,6 +163,11 @@ public class PluginConfiguration : BasePluginConfiguration
/// </summary> /// </summary>
public bool SkipFirstEpisode { get; set; } = true; public bool SkipFirstEpisode { get; set; } = true;
/// <summary>
/// Gets or sets a value indicating whether the introduction in the last episode of a season should be ignored.
/// </summary>
public bool SkipLastEpisode { get; set; } = false;
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the skip button should be displayed for the duration of the intro. /// Gets or sets a value indicating whether the skip button should be displayed for the duration of the intro.
/// </summary> /// </summary>

View File

@ -375,6 +375,18 @@
<br /> <br />
</div> </div>
<div id="divSkipLastEpisode" class="checkboxContainer checkboxContainer-withDescription">
<label class="emby-checkbox-label">
<input id="SkipLastEpisode" type="checkbox" is="emby-checkbox" />
<span>Play intro for last episode of a season</span>
</label>
<div class="fieldDescription">
If checked, auto skip will play the introduction of the last episode in a season.<br />
</div>
<br />
</div>
<div id="divSecondsOfIntroStartToPlay" class="inputContainer"> <div id="divSecondsOfIntroStartToPlay" class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="SecondsOfIntroStartToPlay"> <label class="inputLabel inputLabelUnfocused" for="SecondsOfIntroStartToPlay">
Intro skip delay (in seconds) Intro skip delay (in seconds)
@ -418,7 +430,7 @@
<div class="fieldDescription"> <div class="fieldDescription">
If checked, a skip button will be displayed according to the settings below, while If checked, a skip button will be displayed according to the settings below, while
clients selected in the Auto Skip Client List will skip <strong>automatically</strong>. clients selected in the Auto Skip Client List will skip <strong>automatically</strong>.
<br /> <br />
</div> </div>
</div> </div>
@ -817,6 +829,7 @@
"AutoSkip", "AutoSkip",
"AutoSkipCredits", "AutoSkipCredits",
"SkipFirstEpisode", "SkipFirstEpisode",
"SkipLastEpisode",
"PersistSkipButton", "PersistSkipButton",
"SkipButtonVisible" "SkipButtonVisible"
] ]
@ -850,6 +863,7 @@
var selectAllLibraries = document.querySelector("input#SelectAllLibraries"); var selectAllLibraries = document.querySelector("input#SelectAllLibraries");
var librariesContainer = document.querySelector("div.folderAccessListContainer"); var librariesContainer = document.querySelector("div.folderAccessListContainer");
var skipFirstEpisode = document.querySelector("div#divSkipFirstEpisode"); var skipFirstEpisode = document.querySelector("div#divSkipFirstEpisode");
var skipLastEpisode = document.querySelector("div#divSkipLastEpisode");
var secondsOfIntroStartToPlay = document.querySelector("div#divSecondsOfIntroStartToPlay"); var secondsOfIntroStartToPlay = document.querySelector("div#divSecondsOfIntroStartToPlay");
var autoSkipClientList = document.getElementById("AutoSkipClientList"); var autoSkipClientList = document.getElementById("AutoSkipClientList");
var secondsOfCreditsStartToPlay = document.querySelector("div#divSecondsOfCreditsStartToPlay"); var secondsOfCreditsStartToPlay = document.querySelector("div#divSecondsOfCreditsStartToPlay");
@ -892,10 +906,12 @@
function autoSkipChanged() { function autoSkipChanged() {
if (autoSkip.checked) { if (autoSkip.checked) {
skipFirstEpisode.style.display = 'unset'; skipFirstEpisode.style.display = 'unset';
skipLastEpisode.style.display = 'unset';
autoSkipNotificationText.style.display = 'unset'; autoSkipNotificationText.style.display = 'unset';
secondsOfIntroStartToPlay.style.display = 'unset'; secondsOfIntroStartToPlay.style.display = 'unset';
} else { } else {
skipFirstEpisode.style.display = 'none'; skipFirstEpisode.style.display = 'none';
skipLastEpisode.style.display = 'none';
autoSkipNotificationText.style.display = 'none'; autoSkipNotificationText.style.display = 'none';
secondsOfIntroStartToPlay.style.display = 'none'; secondsOfIntroStartToPlay.style.display = 'none';
} }

View File

@ -87,12 +87,18 @@ public class AutoSkip(
return; return;
} }
// If this is the first episode in the season, and SkipFirstEpisode is false, pretend that we've already sent the seek command for this playback session. // If this is the first episode in the season, and SkipFirstEpisode is true, pretend that we've already sent the seek command for this playback session.
if (Plugin.Instance!.Configuration.SkipFirstEpisode && episodeNumber == 1) if (Plugin.Instance!.Configuration.SkipFirstEpisode && episodeNumber == 1)
{ {
newState = true; newState = true;
} }
// If this is the last episode in the season, and SkipLastEpisode is true, pretend that we've already sent the seek command for this playback session.
if (Plugin.Instance!.Configuration.SkipLastEpisode && episodeNumber == 1)
{
newState = true;
}
// Reset the seek command state for this device. // Reset the seek command state for this device.
lock (_sentSeekCommandLock) lock (_sentSeekCommandLock)
{ {