update javascript connection manager to latest feature set

This commit is contained in:
Luke Pulverenti
2015-02-15 19:33:06 -05:00
parent 18ff8aba74
commit 8051ea9b1b
19 changed files with 221 additions and 58 deletions

View File

@@ -0,0 +1,30 @@

namespace MediaBrowser.Model.ApiClient
{
public class NetworkStatus
{
/// <summary>
/// Gets or sets a value indicating whether this instance is network available.
/// </summary>
/// <value><c>true</c> if this instance is network available; otherwise, <c>false</c>.</value>
public bool IsNetworkAvailable { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is local network available.
/// </summary>
/// <value><c>null</c> if [is local network available] contains no value, <c>true</c> if [is local network available]; otherwise, <c>false</c>.</value>
public bool? IsLocalNetworkAvailable { get; set; }
/// <summary>
/// Gets the is any local network available.
/// </summary>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
public bool GetIsAnyLocalNetworkAvailable()
{
if (!IsLocalNetworkAvailable.HasValue)
{
return IsNetworkAvailable;
}
return IsLocalNetworkAvailable.Value;
}
}
}

View File

@@ -85,12 +85,12 @@ namespace MediaBrowser.Model.Dlna
}
}
public string ToUrl(string baseUrl)
public string ToUrl(string baseUrl, string accessToken)
{
return ToDlnaUrl(baseUrl);
return ToDlnaUrl(baseUrl, accessToken);
}
public string ToDlnaUrl(string baseUrl)
public string ToDlnaUrl(string baseUrl, string accessToken)
{
if (PlayMethod == PlayMethod.DirectPlay)
{
@@ -152,7 +152,47 @@ namespace MediaBrowser.Model.Dlna
return string.Format("Params={0}", string.Join(";", list.ToArray()));
}
public List<SubtitleStreamInfo> GetExternalSubtitles(string baseUrl, bool includeSelectedTrackOnly)
public List<SubtitleStreamInfo> GetExternalSubtitles(bool includeSelectedTrackOnly)
{
List<SubtitleStreamInfo> list = new List<SubtitleStreamInfo>();
// First add the selected track
if (SubtitleStreamIndex.HasValue)
{
foreach (MediaStream stream in MediaSource.MediaStreams)
{
if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value)
{
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
if (info != null)
{
list.Add(info);
}
}
}
}
if (!includeSelectedTrackOnly)
{
foreach (MediaStream stream in MediaSource.MediaStreams)
{
if (stream.Type == MediaStreamType.Subtitle && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value))
{
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
if (info != null)
{
list.Add(info);
}
}
}
}
return list;
}
public List<SubtitleStreamInfo> GetExternalSubtitles(string baseUrl, string accessToken, bool includeSelectedTrackOnly)
{
if (string.IsNullOrEmpty(baseUrl))
{
@@ -173,7 +213,12 @@ namespace MediaBrowser.Model.Dlna
{
if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value)
{
AddSubtitle(list, stream, baseUrl, startPositionTicks);
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
if (info != null)
{
list.Add(info);
}
}
}
}
@@ -184,7 +229,12 @@ namespace MediaBrowser.Model.Dlna
{
if (stream.Type == MediaStreamType.Subtitle && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value))
{
AddSubtitle(list, stream, baseUrl, startPositionTicks);
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
if (info != null)
{
list.Add(info);
}
}
}
}
@@ -192,32 +242,41 @@ namespace MediaBrowser.Model.Dlna
return list;
}
private void AddSubtitle(List<SubtitleStreamInfo> list, MediaStream stream, string baseUrl, long startPositionTicks)
private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream, string baseUrl, string accessToken, long startPositionTicks)
{
var subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile);
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
if (info != null)
{
info.Url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
baseUrl,
ItemId,
MediaSourceId,
StringHelper.ToStringCultureInvariant(stream.Index),
StringHelper.ToStringCultureInvariant(startPositionTicks),
SubtitleFormat);
}
return info;
}
private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream)
{
SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile);
if (subtitleProfile.Method != SubtitleDeliveryMethod.External)
{
return;
return null;
}
string url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
baseUrl,
ItemId,
MediaSourceId,
StringHelper.ToStringCultureInvariant(stream.Index),
StringHelper.ToStringCultureInvariant(startPositionTicks),
SubtitleFormat);
list.Add(new SubtitleStreamInfo
return new SubtitleStreamInfo
{
Url = url,
IsForced = stream.IsForced,
Language = stream.Language,
Name = stream.Language ?? "Unknown",
Format = SubtitleFormat,
Index = stream.Index
});
};
}
/// <summary>

View File

@@ -72,6 +72,7 @@
<Compile Include="ApiClient\IDevice.cs" />
<Compile Include="ApiClient\IServerEvents.cs" />
<Compile Include="ApiClient\GeneralCommandEventArgs.cs" />
<Compile Include="ApiClient\NetworkStatus.cs" />
<Compile Include="ApiClient\RemoteLogoutReason.cs" />
<Compile Include="ApiClient\ServerCredentials.cs" />
<Compile Include="ApiClient\ServerDiscoveryInfo.cs" />

View File

@@ -3,20 +3,57 @@ namespace MediaBrowser.Model.Querying
{
public class EpisodeQuery
{
/// <summary>
/// Gets or sets the user identifier.
/// </summary>
/// <value>The user identifier.</value>
public string UserId { get; set; }
/// <summary>
/// Gets or sets the season identifier.
/// </summary>
/// <value>The season identifier.</value>
public string SeasonId { get; set; }
/// <summary>
/// Gets or sets the series identifier.
/// </summary>
/// <value>The series identifier.</value>
public string SeriesId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is missing.
/// </summary>
/// <value><c>null</c> if [is missing] contains no value, <c>true</c> if [is missing]; otherwise, <c>false</c>.</value>
public bool? IsMissing { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is virtual unaired.
/// </summary>
/// <value><c>null</c> if [is virtual unaired] contains no value, <c>true</c> if [is virtual unaired]; otherwise, <c>false</c>.</value>
public bool? IsVirtualUnaired { get; set; }
/// <summary>
/// Gets or sets the season number.
/// </summary>
/// <value>The season number.</value>
public int? SeasonNumber { get; set; }
/// <summary>
/// Gets or sets the fields.
/// </summary>
/// <value>The fields.</value>
public ItemFields[] Fields { get; set; }
/// <summary>
/// Gets or sets the start index.
/// </summary>
/// <value>The start index.</value>
public int? StartIndex { get; set; }
/// <summary>
/// Gets or sets the limit.
/// </summary>
/// <value>The limit.</value>
public int? Limit { get; set; }
/// <summary>
/// Gets or sets the start item identifier.
/// </summary>
/// <value>The start item identifier.</value>
public string StartItemId { get; set; }
public EpisodeQuery()
{
Fields = new ItemFields[] { };