diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs b/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs index ae9839d..930c194 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkip.cs @@ -133,15 +133,16 @@ public class AutoSkip : IHostedService, IDisposable } // 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; } @@ -164,8 +165,6 @@ public class AutoSkip : IHostedService, IDisposable _logger.LogDebug("Sending seek command to {Session}", deviceId); - var introEnd = (long)intro.IntroEnd - Plugin.Instance.Configuration.SecondsOfIntroToPlay; - _sessionManager.SendPlaystateCommand( session.Id, session.Id, @@ -173,7 +172,7 @@ public class AutoSkip : IHostedService, IDisposable { Command = PlaystateCommand.Seek, ControllingUserId = session.UserId.ToString(), - SeekPositionTicks = introEnd * TimeSpan.TicksPerSecond, + SeekPositionTicks = (long)adjustedEnd * TimeSpan.TicksPerSecond, }, CancellationToken.None); diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkipCredits.cs b/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkipCredits.cs index 878e063..0a5db9b 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkipCredits.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/AutoSkipCredits.cs @@ -132,16 +132,17 @@ public class AutoSkipCredits : IHostedService, IDisposable 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; } @@ -164,8 +165,6 @@ public class AutoSkipCredits : IHostedService, IDisposable _logger.LogDebug("Sending seek command to {Session}", deviceId); - var creditEnd = (long)credit.IntroEnd; - _sessionManager.SendPlaystateCommand( session.Id, session.Id, @@ -173,7 +172,7 @@ public class AutoSkipCredits : IHostedService, IDisposable { Command = PlaystateCommand.Seek, ControllingUserId = session.UserId.ToString(), - SeekPositionTicks = creditEnd * TimeSpan.TicksPerSecond, + SeekPositionTicks = (long)adjustedEnd * TimeSpan.TicksPerSecond, }, CancellationToken.None); diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs index 70a6d2e..35198b8 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs @@ -156,7 +156,17 @@ public class PluginConfiguration : BasePluginConfiguration /// /// Gets or sets the amount of intro to play (in seconds). /// - public int SecondsOfIntroToPlay { get; set; } = 2; + public int RemainingSecondsOfIntro { get; set; } = 2; + + /// + /// Gets or sets the amount of intro at start to play (in seconds). + /// + public int SecondsOfIntroStartToPlay { get; set; } = 0; + + /// + /// Gets or sets the amount of credit at start to play (in seconds). + /// + public int SecondsOfCreditsStartToPlay { get; set; } = 0; // ===== Internal algorithm settings ===== diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html index 68753b0..5c97cf6 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html @@ -365,6 +365,17 @@
+
+ + +
+ Seconds of introduction start that should be played. Defaults to 0. +
+
+
+
+
+ + +
+ Seconds of credits start that should be played. Defaults to 0. +
+
+
+