private async Task <IEnumerable <MediaSourceInfo> > GetMediaSourcesInternal(ILiveTvItem item, CancellationToken cancellationToken)
        {
            IEnumerable <MediaSourceInfo> sources;

            try
            {
                if (item is ILiveTvRecording)
                {
                    sources = await _liveTvManager.GetRecordingMediaSources(item.Id.ToString("N"), cancellationToken)
                              .ConfigureAwait(false);
                }
                else
                {
                    sources = await _liveTvManager.GetChannelMediaSources(item.Id.ToString("N"), cancellationToken)
                              .ConfigureAwait(false);
                }
            }
            catch (NotImplementedException)
            {
                var hasMediaSources = (IHasMediaSources)item;

                sources = _mediaSourceManager.GetStaticMediaSources(hasMediaSources, false)
                          .ToList();
            }

            var list      = sources.ToList();
            var serverUrl = _appHost.LocalApiUrl;

            foreach (var source in list)
            {
                source.Type            = MediaSourceType.Default;
                source.RequiresOpening = true;
                source.BufferMs        = source.BufferMs ?? 1500;

                var openKeys = new List <string>();
                openKeys.Add(item.GetType().Name);
                openKeys.Add(item.Id.ToString("N"));
                openKeys.Add(source.Id ?? string.Empty);
                source.OpenToken = string.Join("|", openKeys.ToArray());

                // Dummy this up so that direct play checks can still run
                if (string.IsNullOrEmpty(source.Path) && source.Protocol == MediaProtocol.Http)
                {
                    source.Path = serverUrl;
                }
            }

            _logger.Debug("MediaSources: {0}", _jsonSerializer.SerializeToString(list));

            return(list);
        }
        private async Task <IEnumerable <MediaSourceInfo> > GetMediaSourcesInternal(ILiveTvItem item, CancellationToken cancellationToken)
        {
            IEnumerable <MediaSourceInfo> sources;

            try
            {
                if (item is ILiveTvRecording)
                {
                    sources = await _liveTvManager.GetRecordingMediaSources(item.Id.ToString("N"), cancellationToken)
                              .ConfigureAwait(false);
                }
                else
                {
                    sources = await _liveTvManager.GetChannelMediaSources(item.Id.ToString("N"), cancellationToken)
                              .ConfigureAwait(false);
                }
            }
            catch (NotImplementedException)
            {
                var hasMediaSources = (IHasMediaSources)item;

                sources = _mediaSourceManager.GetStaticMediaSources(hasMediaSources, false)
                          .ToList();
            }

            var list = sources.ToList();

            foreach (var source in list)
            {
                source.Type            = MediaSourceType.Default;
                source.RequiresOpening = true;
                source.BufferMs        = source.BufferMs ?? 1500;

                var openKeys = new List <string>();
                openKeys.Add(item.GetType().Name);
                openKeys.Add(item.Id.ToString("N"));
                source.OpenToken = string.Join("|", openKeys.ToArray());
            }

            _logger.Debug("MediaSources: {0}", _jsonSerializer.SerializeToString(list));

            return(list);
        }
        private async Task<IEnumerable<MediaSourceInfo>> GetMediaSourcesInternal(ILiveTvItem item, CancellationToken cancellationToken)
        {
            IEnumerable<MediaSourceInfo> sources;

            var forceRequireOpening = false;

            try
            {
                if (item is ILiveTvRecording)
                {
                    sources = await _liveTvManager.GetRecordingMediaSources(item.Id.ToString("N"), cancellationToken)
                                .ConfigureAwait(false);
                }
                else
                {
                    sources = await _liveTvManager.GetChannelMediaSources(item.Id.ToString("N"), cancellationToken)
                                .ConfigureAwait(false);
                }
            }
            catch (NotImplementedException)
            {
                var hasMediaSources = (IHasMediaSources)item;

                sources = _mediaSourceManager.GetStaticMediaSources(hasMediaSources, false)
                   .ToList();

                forceRequireOpening = true;
            }

            var list = sources.ToList();
            var serverUrl = _appHost.LocalApiUrl;

            foreach (var source in list)
            {
                source.Type = MediaSourceType.Default;
                source.BufferMs = source.BufferMs ?? 1500;

                if (source.RequiresOpening || forceRequireOpening)
                {
                    source.RequiresOpening = true;
                }

                if (source.RequiresOpening)
                {
                    var openKeys = new List<string>();
                    openKeys.Add(item.GetType().Name);
                    openKeys.Add(item.Id.ToString("N"));
                    openKeys.Add(source.Id ?? string.Empty);
                    source.OpenToken = string.Join(StreamIdDelimeterString, openKeys.ToArray());
                } 

                // Dummy this up so that direct play checks can still run
                if (string.IsNullOrEmpty(source.Path) && source.Protocol == MediaProtocol.Http)
                {
                    source.Path = serverUrl;
                }
            }

            _logger.Debug("MediaSources: {0}", _jsonSerializer.SerializeToString(list));

            return list;
        }