AutoSkipCredits don't seek use NextTrack
This commit is contained in:
parent
bbfc9e71a3
commit
bae53323fe
@ -28,7 +28,7 @@ public class AutoSkipCredits : IHostedService, IDisposable
|
|||||||
private IUserDataManager _userDataManager;
|
private IUserDataManager _userDataManager;
|
||||||
private ISessionManager _sessionManager;
|
private ISessionManager _sessionManager;
|
||||||
private Timer _playbackTimer = new(1000);
|
private Timer _playbackTimer = new(1000);
|
||||||
private Dictionary<string, bool> _sentSeekCommand;
|
private Dictionary<string, bool> _sentNextCommand;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="AutoSkipCredits"/> class.
|
/// Initializes a new instance of the <see cref="AutoSkipCredits"/> class.
|
||||||
@ -44,7 +44,7 @@ public class AutoSkipCredits : IHostedService, IDisposable
|
|||||||
_userDataManager = userDataManager;
|
_userDataManager = userDataManager;
|
||||||
_sessionManager = sessionManager;
|
_sessionManager = sessionManager;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_sentSeekCommand = new Dictionary<string, bool>();
|
_sentNextCommand = new Dictionary<string, bool>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AutoSkipCreditChanged(object? sender, BasePluginConfiguration e)
|
private void AutoSkipCreditChanged(object? sender, BasePluginConfiguration e)
|
||||||
@ -103,8 +103,8 @@ public class AutoSkipCredits : IHostedService, IDisposable
|
|||||||
{
|
{
|
||||||
var device = session.DeviceId;
|
var device = session.DeviceId;
|
||||||
|
|
||||||
_logger.LogDebug("Resetting seek command state for session {Session}", device);
|
_logger.LogDebug("Resetting next command state for session {Session}", device);
|
||||||
_sentSeekCommand[device] = newState;
|
_sentNextCommand[device] = newState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ public class AutoSkipCredits : IHostedService, IDisposable
|
|||||||
// Don't send the seek command more than once in the same session.
|
// Don't send the seek command more than once in the same session.
|
||||||
lock (_sentSeekCommandLock)
|
lock (_sentSeekCommandLock)
|
||||||
{
|
{
|
||||||
if (_sentSeekCommand.TryGetValue(deviceId, out var sent) && sent)
|
if (_sentNextCommand.TryGetValue(deviceId, out var sent) && sent)
|
||||||
{
|
{
|
||||||
_logger.LogTrace("Already sent seek command for session {Session}", deviceId);
|
_logger.LogTrace("Already sent seek command for session {Session}", deviceId);
|
||||||
continue;
|
continue;
|
||||||
@ -127,7 +127,7 @@ public class AutoSkipCredits : IHostedService, IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assert that credits were detected for this item.
|
// Assert that credits were detected for this item.
|
||||||
if (!Plugin.Instance!.Credits.TryGetValue(itemId, out var credit) || !credit.Valid)
|
if (!Plugin.Instance!.Credits.TryGetValue(itemId, out var credit))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ public class AutoSkipCredits : IHostedService, IDisposable
|
|||||||
adjustedStart,
|
adjustedStart,
|
||||||
credit.IntroEnd);
|
credit.IntroEnd);
|
||||||
|
|
||||||
if (position < adjustedStart || position > credit.IntroEnd)
|
if (position < adjustedStart)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ public class AutoSkipCredits : IHostedService, IDisposable
|
|||||||
CancellationToken.None);
|
CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogDebug("Sending seek command to {Session}", deviceId);
|
_logger.LogDebug("Sending next track command to {Session}", deviceId);
|
||||||
|
|
||||||
var creditEnd = (long)credit.IntroEnd;
|
var creditEnd = (long)credit.IntroEnd;
|
||||||
|
|
||||||
@ -171,17 +171,16 @@ public class AutoSkipCredits : IHostedService, IDisposable
|
|||||||
session.Id,
|
session.Id,
|
||||||
new PlaystateRequest
|
new PlaystateRequest
|
||||||
{
|
{
|
||||||
Command = PlaystateCommand.Seek,
|
Command = PlaystateCommand.NextTrack,
|
||||||
ControllingUserId = session.UserId.ToString("N"),
|
ControllingUserId = session.UserId.ToString(),
|
||||||
SeekPositionTicks = creditEnd * TimeSpan.TicksPerSecond,
|
|
||||||
},
|
},
|
||||||
CancellationToken.None);
|
CancellationToken.None);
|
||||||
|
|
||||||
// Flag that we've sent the seek command so that it's not sent repeatedly
|
// Flag that we've sent the seek command so that it's not sent repeatedly
|
||||||
lock (_sentSeekCommandLock)
|
lock (_sentSeekCommandLock)
|
||||||
{
|
{
|
||||||
_logger.LogTrace("Setting seek command state for session {Session}", deviceId);
|
_logger.LogTrace("Setting next track command state for session {Session}", deviceId);
|
||||||
_sentSeekCommand[deviceId] = true;
|
_sentNextCommand[deviceId] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user