@ -267,12 +267,14 @@ namespace MediaBrowser.Server.Implementations.Dto
PlayableMediaTypes = session . PlayableMediaTypes ,
RemoteEndPoint = session . RemoteEndPoint ,
AdditionalUsers = session . AdditionalUsers ,
SupportsFullscreenToggle = session . SupportsFullscreenToggle
SupportsFullscreenToggle = session . SupportsFullscreenToggle ,
SupportsNavigationControl = session . SupportsNavigationControl ,
SupportsOsdToggle = session . SupportsOsdToggle
} ;
if ( session . NowPlayingItem ! = null )
{
dto . NowPlayingItem = Get BaseItem Info( session . NowPlayingItem ) ;
dto . NowPlayingItem = Get NowPlaying Info( session . NowPlayingItem , session . NowPlayingMediaVersionId , session . NowPlayingRunTimeTicks ) ;
}
if ( session . UserId . HasValue )
@ -288,9 +290,11 @@ namespace MediaBrowser.Server.Implementations.Dto
/// Converts a BaseItem to a BaseItemInfo
/// </summary>
/// <param name="item">The item.</param>
/// <param name="mediaVersionId">The media version identifier.</param>
/// <param name="nowPlayingRuntimeTicks">The now playing runtime ticks.</param>
/// <returns>BaseItemInfo.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
p ublic BaseItemInfo GetBaseItemInfo ( BaseItem item )
p rivate BaseItemInfo GetNowPlayingInfo ( BaseItem item , string mediaVersionId , long? nowPlayingRuntimeTicks )
{
if ( item = = null )
{
@ -303,7 +307,8 @@ namespace MediaBrowser.Server.Implementations.Dto
Name = item . Name ,
MediaType = item . MediaType ,
Type = item . GetClientTypeName ( ) ,
RunTimeTicks = item . RunTimeTicks
RunTimeTicks = nowPlayingRuntimeTicks ,
MediaVersionId = mediaVersionId
} ;
info . PrimaryImageTag = GetImageCacheTag ( item , ImageType . Primary ) ;
@ -1103,9 +1108,7 @@ namespace MediaBrowser.Server.Implementations.Dto
if ( dto . MediaVersions ! = null & & dto . MediaVersions . Count > 0 )
{
chapters = dto . MediaVersions . Where ( i = > i . IsPrimaryVersion )
. SelectMany ( i = > i . Chapters )
. ToList ( ) ;
chapters = _itemRepo . GetChapters ( item . Id ) . Select ( c = > GetChapterInfoDto ( c , item ) ) . ToList ( ) ;
}
else
{
@ -1292,24 +1295,25 @@ namespace MediaBrowser.Server.Implementations.Dto
private List < MediaVersionInfo > GetMediaVersions ( Audio item )
{
var result = new List < MediaVersionInfo > ( ) ;
result . Add ( GetVersionInfo ( item , true ) ) ;
var result = new List < MediaVersionInfo >
{
GetVersionInfo ( item , true )
} ;
return result ;
}
private MediaVersionInfo GetVersionInfo ( Video i , bool isPrimary )
{
var mediaStreams = _itemRepo . GetMediaStreams ( new MediaStreamQuery { ItemId = i . Id } ) . ToList ( ) ;
return new MediaVersionInfo
{
Chapters = _itemRepo . GetChapters ( i . Id ) . Select ( c = > GetChapterInfoDto ( c , i ) ) . ToList ( ) ,
ItemId = i . Id . ToString ( "N" ) ,
Id = i . Id . ToString ( "N" ) ,
IsoType = i . IsoType ,
LocationType = i . LocationType ,
MediaStreams = _ite mRepo. GetM ediaStreams( new MediaStreamQuery { ItemId = i . Id } ) . ToList ( ) ,
Name = GetAlternateVersionName ( i ),
MediaStreams = mediaStreams,
Name = GetAlternateVersionName ( i , mediaStreams ),
Path = GetMappedPath ( i ) ,
RunTimeTicks = i . RunTimeTicks ,
Video3DFormat = i . Video3DFormat ,
@ -1322,7 +1326,7 @@ namespace MediaBrowser.Server.Implementations.Dto
{
return new MediaVersionInfo
{
I temI d = i . Id . ToString ( "N" ) ,
I d = i . Id . ToString ( "N" ) ,
LocationType = i . LocationType ,
MediaStreams = _itemRepo . GetMediaStreams ( new MediaStreamQuery { ItemId = i . Id } ) . ToList ( ) ,
Name = i . Name ,
@ -1351,32 +1355,29 @@ namespace MediaBrowser.Server.Implementations.Dto
return path ;
}
private string GetAlternateVersionName ( Video video )
private string GetAlternateVersionName ( Video video , List < MediaStream > mediaStreams )
{
var name = "" ;
var terms = new List < string > ( ) ;
var videoStream = video . GetDefaultVideoStream ( ) ;
var videoStream = mediaStreams . FirstOrDefault ( i = > i . Type = = MediaStreamType . Video ) ;
var audioStream = mediaStreams . FirstOrDefault ( i = > i . Type = = MediaStreamType . Audio ) ;
if ( video . Video3DFormat . HasValue )
{
name = "3D " + name ;
name = name . Trim ( ) ;
terms . Add ( "3D" ) ;
}
if ( video . VideoType = = VideoType . BluRay )
{
name = name + " " + "Bluray" ;
name = name . Trim ( ) ;
terms . Add ( "Bluray" ) ;
}
else if ( video . VideoType = = VideoType . Dvd )
{
name = name + " " + "DVD" ;
name = name . Trim ( ) ;
terms . Add ( "DVD" ) ;
}
else if ( video . VideoType = = VideoType . HdDvd )
{
name = name + " " + "HD-DVD" ;
name = name . Trim ( ) ;
terms . Add ( "HD-DVD" ) ;
}
else if ( video . VideoType = = VideoType . Iso )
{
@ -1384,18 +1385,17 @@ namespace MediaBrowser.Server.Implementations.Dto
{
if ( video . IsoType . Value = = IsoType . BluRay )
{
name = name + " " + "Bluray" ;
terms. Add ( "Bluray" ) ;
}
else if ( video . IsoType . Value = = IsoType . Dvd )
{
name = name + " " + "DVD" ;
terms. Add ( "DVD" ) ;
}
}
else
{
name = name + " " + "ISO" ;
terms. Add ( "ISO" ) ;
}
name = name . Trim ( ) ;
}
if ( videoStream ! = null )
@ -1404,44 +1404,45 @@ namespace MediaBrowser.Server.Implementations.Dto
{
if ( videoStream . Width . Value > = 3800 )
{
name = name + " " + "4K" ;
name = name . Trim ( ) ;
terms . Add ( "4K" ) ;
}
else if ( videoStream . Width . Value > = 1900 )
{
name = name + " " + "1080P" ;
name = name . Trim ( ) ;
terms . Add ( "1080P" ) ;
}
else if ( videoStream . Width . Value > = 1270 )
{
name = name + " " + "720P" ;
name = name . Trim ( ) ;
terms . Add ( "720P" ) ;
}
else if ( videoStream . Width . Value > = 700 )
{
name = name + " " + "480p" ;
name = name . Trim ( ) ;
terms . Add ( "480P" ) ;
}
else
{
name = name + " " + "SD" ;
name = name . Trim ( ) ;
terms . Add ( "SD" ) ;
}
}
}
if ( videoStream ! = null & & ! string . IsNullOrWhiteSpace ( videoStream . Codec ) )
{
name = name + " " + videoStream . Codec . ToUpper ( ) ;
name = name . Trim ( ) ;
terms . Add ( videoStream . Codec . ToUpper ( ) ) ;
}
if ( string . IsNullOrWhiteSpace ( name ) )
if ( audioStream ! = null )
{
return video . Name ;
var audioCodec = string . Equals ( audioStream . Codec , "dca" , StringComparison . OrdinalIgnoreCase )
? audioStream . Profile
: audioStream . Codec ;
if ( ! string . IsNullOrEmpty ( audioCodec ) )
{
terms . Add ( audioCodec . ToUpper ( ) ) ;
}
}
return name ;
return string . Join ( "/" , terms . ToArray ( ) ) ;
}
private string GetMappedPath ( string path )