Allow configuring show/hide prompt times

This commit is contained in:
ConfusedPolarBear 2022-05-05 18:26:02 -05:00
parent 1c55d749a3
commit 98b0ebe6ce
4 changed files with 41 additions and 5 deletions

View File

@ -22,4 +22,14 @@ public class PluginConfiguration : BasePluginConfiguration
/// If the output of fpcalc should be cached to the filesystem. /// If the output of fpcalc should be cached to the filesystem.
/// </summary> /// </summary>
public bool CacheFingerprints { get; set; } public bool CacheFingerprints { get; set; }
/// <summary>
/// Seconds before the intro starts to show the skip prompt at.
/// </summary>
public int ShowPromptAdjustment { get; set; } = 5;
/// <summary>
/// Seconds after the intro starts to hide the skip prompt at.
/// </summary>
public int HidePromptAdjustment { get; set; } = 10;
} }

View File

@ -20,6 +20,23 @@
Caching fingerprints avoids having to re-run fpcalc on each file, at the expense of disk usage. Caching fingerprints avoids having to re-run fpcalc on each file, at the expense of disk usage.
</div> </div>
</div> </div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="AnInteger">Show skip prompt at</label>
<input id="ShowPromptAdjustment" type="number" is="emby-input" min="0" />
<div class="fieldDescription">
Seconds before the introduction starts to display the skip prompt at.
</div>
</div>
<div class="inputContainer">
<label class="inputLabel inputLabelUnfocused" for="AnInteger">Hide skip prompt at</label>
<input id="HidePromptAdjustment" type="number" is="emby-input" min="0" />
<div class="fieldDescription">
Seconds after the introduction starts to hide the skip prompt at.
</div>
</div>
<div> <div>
<button is="emby-button" type="submit" class="raised button-submit block emby-button"> <button is="emby-button" type="submit" class="raised button-submit block emby-button">
<span>Save</span> <span>Save</span>
@ -38,6 +55,10 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration(TemplateConfig.pluginUniqueId).then(function (config) { ApiClient.getPluginConfiguration(TemplateConfig.pluginUniqueId).then(function (config) {
document.querySelector('#CacheFingerprints').checked = config.CacheFingerprints; document.querySelector('#CacheFingerprints').checked = config.CacheFingerprints;
document.querySelector('#ShowPromptAdjustment').value = config.ShowPromptAdjustment;
document.querySelector('#HidePromptAdjustment').value = config.HidePromptAdjustment;
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
}); });
}); });
@ -47,6 +68,10 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration(TemplateConfig.pluginUniqueId).then(function (config) { ApiClient.getPluginConfiguration(TemplateConfig.pluginUniqueId).then(function (config) {
config.CacheFingerprints = document.querySelector('#CacheFingerprints').checked; config.CacheFingerprints = document.querySelector('#CacheFingerprints').checked;
config.ShowPromptAdjustment = document.querySelector("#ShowPromptAdjustment").value;
config.HidePromptAdjustment = document.querySelector("#HidePromptAdjustment").value;
ApiClient.updatePluginConfiguration(TemplateConfig.pluginUniqueId, config).then(function (result) { ApiClient.updatePluginConfiguration(TemplateConfig.pluginUniqueId, config).then(function (result) {
Dashboard.processPluginConfigurationUpdateResult(result); Dashboard.processPluginConfigurationUpdateResult(result);
}); });

View File

@ -42,6 +42,11 @@ public class SkipIntroController : ControllerBase
return NotFound(); return NotFound();
} }
// Populate the prompt show/hide times.
var config = Plugin.Instance!.Configuration;
intro.ShowSkipPromptAt = Math.Max(0, intro.IntroStart - config.ShowPromptAdjustment);
intro.HideSkipPromptAt = intro.IntroStart + config.HidePromptAdjustment;
return intro; return intro;
} }
} }

View File

@ -350,16 +350,12 @@ public class FingerprinterTask : IScheduledTask {
private static void storeIntro(Guid episode, double introStart, double introEnd) private static void storeIntro(Guid episode, double introStart, double introEnd)
{ {
// Recommend that the skip button appears 5 seconds ahead of the intro
// and that it disappears 10 seconds after the intro begins.
Plugin.Instance!.Intros[episode] = new Intro() Plugin.Instance!.Intros[episode] = new Intro()
{ {
EpisodeId = episode, EpisodeId = episode,
Valid = introEnd > 0, Valid = introEnd > 0,
IntroStart = introStart, IntroStart = introStart,
IntroEnd = introEnd, IntroEnd = introEnd
ShowSkipPromptAt = Math.Max(0, introStart - 5),
HideSkipPromptAt = introStart + 10
}; };
} }