Apply suggestions from code review

Co-authored-by: Claus Vium <cvium@users.noreply.github.com>
This commit is contained in:
Joe Rogers 2021-11-19 22:40:42 +01:00 committed by GitHub
parent 9ba7bf96ef
commit 88baff5693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,15 +83,18 @@ namespace MediaBrowser.Providers.MediaInfo
// If we know the duration, grab it from 10% into the video. Otherwise just 10 seconds in. // If we know the duration, grab it from 10% into the video. Otherwise just 10 seconds in.
// Always use 10 seconds for dvd because our duration could be out of whack // Always use 10 seconds for dvd because our duration could be out of whack
var imageOffset = item.VideoType != VideoType.Dvd && item.RunTimeTicks is > 0 var imageOffset = item.VideoType != VideoType.Dvd && item.RunTimeTicks > 0
? TimeSpan.FromTicks(item.RunTimeTicks.Value / 10) ? TimeSpan.FromTicks(item.RunTimeTicks.Value / 10)
: TimeSpan.FromSeconds(10); : TimeSpan.FromSeconds(10);
var defaultQuery = new MediaStreamQuery { ItemId = item.Id, Index = item.DefaultVideoStreamIndex }; var query = new MediaStreamQuery { ItemId = item.Id, Index = item.DefaultVideoStreamIndex };
var videoQuery = new MediaStreamQuery { ItemId = item.Id, Type = MediaStreamType.Video }; var videoStream = _mediaSourceManager.GetMediaStreams(query).FirstOrDefault();
if (videoStream == null)
var videoStream = _mediaSourceManager.GetMediaStreams(defaultQuery).FirstOrDefault() {
?? _mediaSourceManager.GetMediaStreams(videoQuery).FirstOrDefault(); query.Type = MediaStreamType.Video;
query.Index = null;
videoStream = _mediaSourceManager.GetMediaStreams(query).FirstOrDefault();
}
if (videoStream == null) if (videoStream == null)
{ {