Merge remote-tracking branch 'upstream/master'

pull/702/head
Tim Hobbs 11 years ago
commit c8cdc6099a

@ -1368,7 +1368,7 @@ namespace MediaBrowser.Api.Playback
mediaUrl = streamInfo.Url; mediaUrl = streamInfo.Url;
} }
if (!string.IsNullOrEmpty(path) && File.Exists(path)) if (!string.IsNullOrEmpty(path))
{ {
state.MediaPath = path; state.MediaPath = path;
state.IsRemote = false; state.IsRemote = false;
@ -1381,7 +1381,7 @@ namespace MediaBrowser.Api.Playback
state.RunTimeTicks = recording.RunTimeTicks; state.RunTimeTicks = recording.RunTimeTicks;
if (recording.RecordingInfo.Status == RecordingStatus.InProgress && !state.IsRemote) if (recording.RecordingInfo.Status == RecordingStatus.InProgress)
{ {
await Task.Delay(1000, cancellationToken).ConfigureAwait(false); await Task.Delay(1000, cancellationToken).ConfigureAwait(false);
} }
@ -1404,7 +1404,7 @@ namespace MediaBrowser.Api.Playback
state.LiveTvStreamId = streamInfo.Id; state.LiveTvStreamId = streamInfo.Id;
if (!string.IsNullOrEmpty(streamInfo.Path) && File.Exists(streamInfo.Path)) if (!string.IsNullOrEmpty(streamInfo.Path))
{ {
state.MediaPath = streamInfo.Path; state.MediaPath = streamInfo.Path;
state.IsRemote = false; state.IsRemote = false;
@ -1749,11 +1749,11 @@ namespace MediaBrowser.Api.Playback
if (isStaticallyStreamed) if (isStaticallyStreamed)
{ {
flagValue = flagValue | DlnaFlags.DLNA_ORG_FLAG_BYTE_BASED_SEEK; //flagValue = flagValue | DlnaFlags.DLNA_ORG_FLAG_BYTE_BASED_SEEK;
} }
else if (state.RunTimeTicks.HasValue) else if (state.RunTimeTicks.HasValue)
{ {
flagValue = flagValue | DlnaFlags.DLNA_ORG_FLAG_TIME_BASED_SEEK; //flagValue = flagValue | DlnaFlags.DLNA_ORG_FLAG_TIME_BASED_SEEK;
} }
var dlnaflags = string.Format(";DLNA.ORG_FLAGS={0}000000000000000000000000", var dlnaflags = string.Format(";DLNA.ORG_FLAGS={0}000000000000000000000000",

@ -15,14 +15,12 @@ namespace MediaBrowser.Api.UserLibrary
/// <summary> /// <summary>
/// Class GetArtists /// Class GetArtists
/// </summary> /// </summary>
[Route("/Artists", "GET")] [Route("/Artists", "GET", Summary = "Gets all artists from a given item, folder, or the entire library")]
[Api(Description = "Gets all artists from a given item, folder, or the entire library")]
public class GetArtists : GetItemsByName public class GetArtists : GetItemsByName
{ {
} }
[Route("/Artists/{Name}", "GET")] [Route("/Artists/{Name}", "GET", Summary = "Gets an artist, by name")]
[Api(Description = "Gets an artist, by name")]
public class GetArtist : IReturn<BaseItemDto> public class GetArtist : IReturn<BaseItemDto>
{ {
/// <summary> /// <summary>
@ -112,7 +110,8 @@ namespace MediaBrowser.Api.UserLibrary
protected override IEnumerable<MusicArtist> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items) protected override IEnumerable<MusicArtist> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
{ {
return items return items
.OfType<Audio>() .OfType<IHasArtist>()
.Where(i => !(i is MusicAlbum))
.SelectMany(i => i.AllArtists) .SelectMany(i => i.AllArtists)
.Distinct(StringComparer.OrdinalIgnoreCase) .Distinct(StringComparer.OrdinalIgnoreCase)
.Select(name => .Select(name =>

@ -1,4 +1,5 @@
 using System.Collections.Generic;
namespace MediaBrowser.Controller.Entities.Audio namespace MediaBrowser.Controller.Entities.Audio
{ {
public interface IHasAlbumArtist public interface IHasAlbumArtist
@ -9,5 +10,7 @@ namespace MediaBrowser.Controller.Entities.Audio
public interface IHasArtist public interface IHasArtist
{ {
bool HasArtist(string name); bool HasArtist(string name);
List<string> AllArtists { get; }
} }
} }

@ -31,6 +31,23 @@ namespace MediaBrowser.Controller.Entities.Audio
} }
} }
[IgnoreDataMember]
public List<string> AllArtists
{
get
{
var list = new List<string>();
if (!string.IsNullOrEmpty(AlbumArtist))
{
list.Add(AlbumArtist);
}
list.AddRange(Artists);
return list;
}
}
/// <summary> /// <summary>
/// Gets or sets the tags. /// Gets or sets the tags.
/// </summary> /// </summary>

@ -3,7 +3,9 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
namespace MediaBrowser.Controller.Entities namespace MediaBrowser.Controller.Entities
{ {
@ -33,6 +35,23 @@ namespace MediaBrowser.Controller.Entities
/// <value>The revenue.</value> /// <value>The revenue.</value>
public double? Revenue { get; set; } public double? Revenue { get; set; }
[IgnoreDataMember]
public List<string> AllArtists
{
get
{
var list = new List<string>();
if (!string.IsNullOrEmpty(Artist))
{
list.Add(Artist);
}
return list;
}
}
/// <summary> /// <summary>
/// Determines whether the specified name has artist. /// Determines whether the specified name has artist.
/// </summary> /// </summary>

@ -167,25 +167,28 @@ namespace MediaBrowser.Dlna.PlayTo
if (_currentItem == null || _device.IsStopped) if (_currentItem == null || _device.IsStopped)
return; return;
if (!_playbackStarted) var playlistItem = Playlist.FirstOrDefault(p => p.PlayState == 1);
if (playlistItem != null)
{ {
await _sessionManager.OnPlaybackStart(new PlaybackInfo if (!_playbackStarted)
{ {
Item = _currentItem, await _sessionManager.OnPlaybackStart(new PlaybackInfo
SessionId = _session.Id, {
CanSeek = true, Item = _currentItem,
QueueableMediaTypes = new List<string> { _currentItem.MediaType } SessionId = _session.Id,
CanSeek = true,
}).ConfigureAwait(false); QueueableMediaTypes = new List<string> { _currentItem.MediaType },
MediaSourceId = playlistItem.MediaSourceId,
AudioStreamIndex = playlistItem.AudioStreamIndex,
SubtitleStreamIndex = playlistItem.SubtitleStreamIndex
_playbackStarted = true; }).ConfigureAwait(false);
}
if ((_device.IsPlaying || _device.IsPaused)) _playbackStarted = true;
{ }
var playlistItem = Playlist.FirstOrDefault(p => p.PlayState == 1);
if (playlistItem != null) if ((_device.IsPlaying || _device.IsPaused))
{ {
var ticks = _device.Position.Ticks; var ticks = _device.Position.Ticks;
@ -487,7 +490,7 @@ namespace MediaBrowser.Dlna.PlayTo
return (contentFeatures + orgOp + orgCi + dlnaflags).Trim(';'); return (contentFeatures + orgOp + orgCi + dlnaflags).Trim(';');
} }
private PlaylistItem GetPlaylistItem(BaseItem item, List<MediaStream> mediaStreams, DeviceProfile profile) private PlaylistItem GetPlaylistItem(BaseItem item, List<MediaStream> mediaStreams, DeviceProfile profile)
{ {
var video = item as Video; var video = item as Video;
@ -563,10 +566,10 @@ namespace MediaBrowser.Dlna.PlayTo
_logger.Debug("{0} - SetAvTransport Uri: {1} DlnaHeaders: {2}", _device.Properties.Name, nextTrack.StreamUrl, dlnaheaders); _logger.Debug("{0} - SetAvTransport Uri: {1} DlnaHeaders: {2}", _device.Properties.Name, nextTrack.StreamUrl, dlnaheaders);
await _device.SetAvTransport(nextTrack.StreamUrl, dlnaheaders, nextTrack.Didl); await _device.SetAvTransport(nextTrack.StreamUrl, dlnaheaders, nextTrack.Didl);
if (nextTrack.StartPositionTicks > 0 && !nextTrack.Transcode) if (nextTrack.StartPositionTicks > 0 && !nextTrack.Transcode)
await _device.Seek(TimeSpan.FromTicks(nextTrack.StartPositionTicks)); await _device.Seek(TimeSpan.FromTicks(nextTrack.StartPositionTicks));
return true; return true;
} }

@ -64,7 +64,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{ {
throw new ArgumentNullException("contentType"); throw new ArgumentNullException("contentType");
} }
RangeHeader = rangeHeader; RangeHeader = rangeHeader;
SourceStream = source; SourceStream = source;
IsHeadRequest = isHeadRequest; IsHeadRequest = isHeadRequest;
@ -98,11 +98,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer
RangeStart = requestedRange.Key; RangeStart = requestedRange.Key;
RangeLength = 1 + RangeEnd - RangeStart; RangeLength = 1 + RangeEnd - RangeStart;
// Content-Length is the length of what we're serving, not the original content // Content-Length is the length of what we're serving, not the original content
Options["Content-Length"] = RangeLength.ToString(UsCulture); Options["Content-Length"] = RangeLength.ToString(UsCulture);
Options["Content-Range"] = string.Format("bytes {0}-{1}/{2}", RangeStart, RangeEnd, TotalContentLength); Options["Content-Range"] = string.Format("bytes {0}-{1}/{2}", RangeStart, RangeEnd, TotalContentLength);
if (RangeStart > 0) if (RangeStart > 0)
{ {
SourceStream.Position = RangeStart; SourceStream.Position = RangeStart;
@ -178,19 +178,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer
using (var source = SourceStream) using (var source = SourceStream)
{ {
// If the requested range is "0-", we can optimize by just doing a stream copy //Since we've already set the postion of the sourcestream, just copy the remains to the output
if (RangeEnd == TotalContentLength - 1) await source.CopyToAsync(responseStream).ConfigureAwait(false);
{
await source.CopyToAsync(responseStream).ConfigureAwait(false);
}
else
{
// Read the bytes we need
var buffer = new byte[Convert.ToInt32(RangeLength)];
await source.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
await responseStream.WriteAsync(buffer, 0, Convert.ToInt32(RangeLength)).ConfigureAwait(false);
}
} }
} }

Loading…
Cancel
Save