stub out config setting to remember tracks

This commit is contained in:
Luke Pulverenti 2016-02-21 16:15:36 -05:00
parent 10c1225a84
commit 299ac388b3
3 changed files with 31 additions and 10 deletions

View File

@ -48,11 +48,17 @@ namespace MediaBrowser.Model.Configuration
public bool HidePlayedInLatest { get; set; }
public bool DisplayChannelsInline { get; set; }
public bool RememberAudioSelections { get; set; }
public bool RememberSubtitleSelections { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="UserConfiguration" /> class.
/// </summary>
public UserConfiguration()
{
RememberAudioSelections = true;
RememberSubtitleSelections = true;
HidePlayedInLatest = true;
PlayDefaultAudioTrack = true;

View File

@ -276,7 +276,7 @@ namespace MediaBrowser.Server.Implementations.Library
private void SetDefaultSubtitleStreamIndex(MediaSourceInfo source, UserItemData userData, User user)
{
if (userData.SubtitleStreamIndex.HasValue)
if (userData.SubtitleStreamIndex.HasValue && user.Configuration.RememberSubtitleSelections)
{
var index = userData.SubtitleStreamIndex.Value;
// Make sure the saved index is still valid
@ -307,7 +307,7 @@ namespace MediaBrowser.Server.Implementations.Library
private void SetDefaultAudioStreamIndex(MediaSourceInfo source, UserItemData userData, User user)
{
if (userData.AudioStreamIndex.HasValue)
if (userData.AudioStreamIndex.HasValue && user.Configuration.RememberAudioSelections)
{
var index = userData.AudioStreamIndex.Value;
// Make sure the saved index is still valid

View File

@ -680,7 +680,7 @@ namespace MediaBrowser.Server.Implementations.Session
foreach (var user in users)
{
await OnPlaybackProgress(user.Id, key, libraryItem, info).ConfigureAwait(false);
await OnPlaybackProgress(user, key, libraryItem, info).ConfigureAwait(false);
}
}
@ -712,9 +712,9 @@ namespace MediaBrowser.Server.Implementations.Session
StartIdleCheckTimer();
}
private async Task OnPlaybackProgress(Guid userId, string userDataKey, BaseItem item, PlaybackProgressInfo info)
private async Task OnPlaybackProgress(User user, string userDataKey, BaseItem item, PlaybackProgressInfo info)
{
var data = _userDataRepository.GetUserData(userId, userDataKey);
var data = _userDataRepository.GetUserData(user.Id, userDataKey);
var positionTicks = info.PositionTicks;
@ -722,17 +722,32 @@ namespace MediaBrowser.Server.Implementations.Session
{
_userDataRepository.UpdatePlayState(item, data, positionTicks.Value);
UpdatePlaybackSettings(info, data);
UpdatePlaybackSettings(user, info, data);
await _userDataRepository.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false);
await _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false);
}
}
private void UpdatePlaybackSettings(PlaybackProgressInfo info, UserItemData data)
private void UpdatePlaybackSettings(User user, PlaybackProgressInfo info, UserItemData data)
{
if (user.Configuration.RememberAudioSelections)
{
data.AudioStreamIndex = info.AudioStreamIndex;
}
else
{
data.AudioStreamIndex = null;
}
if (user.Configuration.RememberSubtitleSelections)
{
data.SubtitleStreamIndex = info.SubtitleStreamIndex;
}
else
{
data.SubtitleStreamIndex = null;
}
}
/// <summary>
/// Used to report that playback has ended for an item