AutoSkip: allow to adjust the intro/credit playback duration (#238)
Co-authored-by: rlauu <46294892+rlauu@users.noreply.github.com> Co-authored-by: rlauuzo <46294892+rlauuzo@users.noreply.github.com> Co-authored-by: CasuallyFilthy <adamsdeloach@yahoo.com>
This commit is contained in:
parent
d351a6225e
commit
252e30cde0
@ -149,15 +149,16 @@ public class AutoSkip : IServerEntryPoint
|
||||
}
|
||||
|
||||
// Seek is unreliable if called at the very start of an episode.
|
||||
var adjustedStart = Math.Max(5, intro.IntroStart);
|
||||
var adjustedStart = Math.Max(5, intro.IntroStart + Plugin.Instance.Configuration.SecondsOfIntroStartToPlay);
|
||||
var adjustedEnd = intro.IntroEnd - Plugin.Instance.Configuration.RemainingSecondsOfIntro;
|
||||
|
||||
_logger.LogTrace(
|
||||
"Playback position is {Position}, intro runs from {Start} to {End}",
|
||||
position,
|
||||
adjustedStart,
|
||||
intro.IntroEnd);
|
||||
adjustedEnd);
|
||||
|
||||
if (position < adjustedStart || position > intro.IntroEnd)
|
||||
if (position < adjustedStart || position > adjustedEnd)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -180,8 +181,6 @@ public class AutoSkip : IServerEntryPoint
|
||||
|
||||
_logger.LogDebug("Sending seek command to {Session}", deviceId);
|
||||
|
||||
var introEnd = (long)intro.IntroEnd - Plugin.Instance!.Configuration.SecondsOfIntroToPlay;
|
||||
|
||||
_sessionManager.SendPlaystateCommand(
|
||||
session.Id,
|
||||
session.Id,
|
||||
@ -189,7 +188,7 @@ public class AutoSkip : IServerEntryPoint
|
||||
{
|
||||
Command = PlaystateCommand.Seek,
|
||||
ControllingUserId = session.UserId.ToString("N"),
|
||||
SeekPositionTicks = introEnd * TimeSpan.TicksPerSecond,
|
||||
SeekPositionTicks = (long)adjustedEnd * TimeSpan.TicksPerSecond,
|
||||
},
|
||||
CancellationToken.None);
|
||||
|
||||
|
@ -142,16 +142,17 @@ public class AutoSkipCredits : IServerEntryPoint
|
||||
continue;
|
||||
}
|
||||
|
||||
// Seek is unreliable if called at the very start of an episode.
|
||||
var adjustedStart = Math.Max(5, credit.IntroStart);
|
||||
// Seek is unreliable if called at the very end of an episode.
|
||||
var adjustedStart = credit.IntroStart + Plugin.Instance.Configuration.SecondsOfCreditsStartToPlay;
|
||||
var adjustedEnd = credit.IntroEnd - Plugin.Instance.Configuration.RemainingSecondsOfIntro;
|
||||
|
||||
_logger.LogTrace(
|
||||
"Playback position is {Position}, credits run from {Start} to {End}",
|
||||
position,
|
||||
adjustedStart,
|
||||
credit.IntroEnd);
|
||||
adjustedEnd);
|
||||
|
||||
if (position < adjustedStart || position > credit.IntroEnd)
|
||||
if (position < adjustedStart || position > adjustedEnd)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -174,8 +175,6 @@ public class AutoSkipCredits : IServerEntryPoint
|
||||
|
||||
_logger.LogDebug("Sending seek command to {Session}", deviceId);
|
||||
|
||||
var creditEnd = (long)credit.IntroEnd;
|
||||
|
||||
_sessionManager.SendPlaystateCommand(
|
||||
session.Id,
|
||||
session.Id,
|
||||
@ -183,7 +182,7 @@ public class AutoSkipCredits : IServerEntryPoint
|
||||
{
|
||||
Command = PlaystateCommand.Seek,
|
||||
ControllingUserId = session.UserId.ToString("N"),
|
||||
SeekPositionTicks = creditEnd * TimeSpan.TicksPerSecond,
|
||||
SeekPositionTicks = (long)adjustedEnd * TimeSpan.TicksPerSecond,
|
||||
},
|
||||
CancellationToken.None);
|
||||
|
||||
|
@ -161,7 +161,17 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of intro to play (in seconds).
|
||||
/// </summary>
|
||||
public int SecondsOfIntroToPlay { get; set; } = 2;
|
||||
public int RemainingSecondsOfIntro { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of intro at start to play (in seconds).
|
||||
/// </summary>
|
||||
public int SecondsOfIntroStartToPlay { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of credit at start to play (in seconds).
|
||||
/// </summary>
|
||||
public int SecondsOfCreditsStartToPlay { get; set; } = 0;
|
||||
|
||||
// ===== Internal algorithm settings =====
|
||||
|
||||
|
@ -365,6 +365,17 @@
|
||||
<br />
|
||||
</div>
|
||||
|
||||
<div id="divSecondsOfIntroStartToPlay" class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="SecondsOfIntroStartToPlay">
|
||||
Intro playback duration (in seconds)
|
||||
</label>
|
||||
<input id="SecondsOfIntroStartToPlay" type="number" is="emby-input" min="0" />
|
||||
<div class="fieldDescription">
|
||||
Seconds of introduction start that should be played. Defaults to 0.
|
||||
</div>
|
||||
<br />
|
||||
</div>
|
||||
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="AutoSkipCredits" type="checkbox" is="emby-checkbox" />
|
||||
@ -378,6 +389,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="divSecondsOfCreditsStartToPlay" class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="SecondsOfCreditsStartToPlay">
|
||||
Credit playback duration (in seconds)
|
||||
</label>
|
||||
<input id="SecondsOfCreditsStartToPlay" type="number" is="emby-input" min="0" />
|
||||
<div class="fieldDescription">
|
||||
Seconds of credits start that should be played. Defaults to 0.
|
||||
</div>
|
||||
<br />
|
||||
</div>
|
||||
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="SkipButtonVisible" type="checkbox" is="emby-checkbox" />
|
||||
@ -427,10 +449,10 @@
|
||||
<br />
|
||||
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="SecondsOfIntroToPlay">
|
||||
<label class="inputLabel inputLabelUnfocused" for="RemainingSecondsOfIntro">
|
||||
Intro playback duration (in seconds)
|
||||
</label>
|
||||
<input id="SecondsOfIntroToPlay" type="number" is="emby-input" min="0" />
|
||||
<input id="RemainingSecondsOfIntro" type="number" is="emby-input" min="0" />
|
||||
<div class="fieldDescription">
|
||||
Seconds of introduction ending that should be played. Defaults to 2.
|
||||
</div>
|
||||
@ -648,7 +670,9 @@
|
||||
// playback
|
||||
"ShowPromptAdjustment",
|
||||
"HidePromptAdjustment",
|
||||
"SecondsOfIntroToPlay",
|
||||
"RemainingSecondsOfIntro",
|
||||
"SecondsOfIntroStartToPlay",
|
||||
"SecondsOfCreditsStartToPlay",
|
||||
// internals
|
||||
"SilenceDetectionMaximumNoise",
|
||||
"SilenceDetectionMinimumDuration",
|
||||
@ -691,6 +715,8 @@
|
||||
|
||||
var autoSkip = document.querySelector("input#AutoSkip");
|
||||
var skipFirstEpisode = document.querySelector("div#divSkipFirstEpisode");
|
||||
var secondsOfIntroStartToPlay = document.querySelector("div#divSecondsOfIntroStartToPlay");
|
||||
var secondsOfCreditsStartToPlay = document.querySelector("div#divSecondsOfCreditsStartToPlay");
|
||||
var autoSkipNotificationText = document.querySelector("div#divAutoSkipNotificationText");
|
||||
var autoSkipCredits = document.querySelector("input#AutoSkipCredits");
|
||||
var autoSkipCreditsNotificationText = document.querySelector("div#divAutoSkipCreditsNotificationText");
|
||||
@ -699,9 +725,11 @@
|
||||
if (autoSkip.checked) {
|
||||
skipFirstEpisode.style.display = 'unset';
|
||||
autoSkipNotificationText.style.display = 'unset';
|
||||
secondsOfIntroStartToPlay.style.display = 'unset';
|
||||
} else {
|
||||
skipFirstEpisode.style.display = 'none';
|
||||
autoSkipNotificationText.style.display = 'none';
|
||||
secondsOfIntroStartToPlay.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
@ -710,8 +738,10 @@
|
||||
async function autoSkipCreditsChanged() {
|
||||
if (autoSkipCredits.checked) {
|
||||
autoSkipCreditsNotificationText.style.display = 'unset';
|
||||
secondsOfCreditsStartToPlay.style.display = 'unset';
|
||||
} else {
|
||||
autoSkipCreditsNotificationText.style.display = 'none';
|
||||
secondsOfCreditsStartToPlay.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,8 @@ public class SkipIntroController : ControllerBase
|
||||
// Operate on a copy to avoid mutating the original Intro object stored in the dictionary.
|
||||
var segment = new Intro(timestamp);
|
||||
|
||||
var config = Plugin.Instance!.Configuration;
|
||||
segment.IntroEnd -= config.SecondsOfIntroToPlay;
|
||||
var config = Plugin.Instance.Configuration;
|
||||
segment.IntroEnd -= config.RemainingSecondsOfIntro;
|
||||
if (config.PersistSkipButton)
|
||||
{
|
||||
segment.ShowSkipPromptAt = segment.IntroStart;
|
||||
|
Loading…
x
Reference in New Issue
Block a user