mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-23 15:30:56 -04:00
Split resume function for Audiobooks
This commit is contained in:
parent
054adf6379
commit
99adbf0497
@ -14,6 +14,7 @@ using MediaBrowser.Controller.Persistence;
|
|||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using Book = MediaBrowser.Controller.Entities.Book;
|
using Book = MediaBrowser.Controller.Entities.Book;
|
||||||
|
using AudioBook = MediaBrowser.Controller.Entities.AudioBook;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.Library
|
namespace Emby.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
@ -219,7 +220,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
var hasRuntime = runtimeTicks > 0;
|
var hasRuntime = runtimeTicks > 0;
|
||||||
|
|
||||||
// If a position has been reported, and if we know the duration
|
// If a position has been reported, and if we know the duration
|
||||||
if (positionTicks > 0 && hasRuntime)
|
if (positionTicks > 0 && hasRuntime && !(item is AudioBook))
|
||||||
{
|
{
|
||||||
var pctIn = decimal.Divide(positionTicks, runtimeTicks) * 100;
|
var pctIn = decimal.Divide(positionTicks, runtimeTicks) * 100;
|
||||||
|
|
||||||
@ -245,6 +246,24 @@ namespace Emby.Server.Implementations.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (positionTicks > 0 && hasRuntime && (item is AudioBook))
|
||||||
|
{
|
||||||
|
var minIn = TimeSpan.FromTicks(positionTicks).TotalSeconds / 60;
|
||||||
|
// 10,000 ticks per millisecond * 60,000 milliseconds per minute = 600,000,000 ticks per minute
|
||||||
|
var minOut = (runtimeTicks - positionTicks) / 600000000;
|
||||||
|
|
||||||
|
if (minIn > _config.Configuration.MinAudiobookResume)
|
||||||
|
{
|
||||||
|
// ignore progress during the beginning
|
||||||
|
positionTicks = 0;
|
||||||
|
}
|
||||||
|
else if (minOut < _config.Configuration.MaxAudiobookResume || positionTicks >= runtimeTicks)
|
||||||
|
{
|
||||||
|
// mark as completed close to the end
|
||||||
|
positionTicks = 0;
|
||||||
|
data.Played = playedToCompletion = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (!hasRuntime)
|
else if (!hasRuntime)
|
||||||
{
|
{
|
||||||
// If we don't know the runtime we'll just have to assume it was fully played
|
// If we don't know the runtime we'll just have to assume it was fully played
|
||||||
|
Loading…
x
Reference in New Issue
Block a user