Beispiel #1
0
        private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream)
        {
            SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile, Context);

            if (subtitleProfile.Method != SubtitleDeliveryMethod.External)
            {
                return(null);
            }

            return(new SubtitleStreamInfo
            {
                IsForced = stream.IsForced,
                Language = stream.Language,
                Name = stream.Language ?? "Unknown",
                Format = SubtitleFormat,
                Index = stream.Index
            });
        }
Beispiel #2
0
        private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream, string baseUrl, string accessToken, long startPositionTicks, SubtitleProfile[] subtitleProfiles, ITranscoderSupport transcoderSupport)
        {
            var subtitleProfile = StreamBuilder.GetSubtitleProfile(MediaSource, stream, subtitleProfiles, PlayMethod, transcoderSupport, Container, SubProtocol);
            var info            = new SubtitleStreamInfo
            {
                IsForced       = stream.IsForced,
                Language       = stream.Language,
                Name           = stream.Language ?? "Unknown",
                Format         = subtitleProfile.Format,
                Index          = stream.Index,
                DeliveryMethod = subtitleProfile.Method,
                DisplayTitle   = stream.DisplayTitle
            };

            if (info.DeliveryMethod == SubtitleDeliveryMethod.External)
            {
                if (MediaSource.Protocol == MediaProtocol.File || !string.Equals(stream.Codec, subtitleProfile.Format, StringComparison.OrdinalIgnoreCase) || !stream.IsExternal)
                {
                    info.Url = string.Format(
                        CultureInfo.InvariantCulture,
                        "{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
                        baseUrl,
                        ItemId,
                        MediaSourceId,
                        stream.Index.ToString(CultureInfo.InvariantCulture),
                        startPositionTicks.ToString(CultureInfo.InvariantCulture),
                        subtitleProfile.Format);

                    if (!string.IsNullOrEmpty(accessToken))
                    {
                        info.Url += "?api_key=" + accessToken;
                    }

                    info.IsExternalUrl = false;
                }
                else
                {
                    info.Url           = stream.Path;
                    info.IsExternalUrl = true;
                }
            }

            return(info);
        }
Beispiel #3
0
        private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream, string baseUrl, string accessToken, long startPositionTicks, SubtitleProfile[] subtitleProfiles)
        {
            SubtitleProfile    subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, subtitleProfiles, PlayMethod, SubProtocol, Container);
            SubtitleStreamInfo info            = new SubtitleStreamInfo
            {
                IsForced       = stream.IsForced,
                Language       = stream.Language,
                Name           = stream.Language ?? "Unknown",
                Format         = subtitleProfile.Format,
                Index          = stream.Index,
                DeliveryMethod = subtitleProfile.Method,
                DisplayTitle   = stream.DisplayTitle
            };

            if (info.DeliveryMethod == SubtitleDeliveryMethod.External)
            {
                if (MediaSource.Protocol == MediaProtocol.File || !StringHelper.EqualsIgnoreCase(stream.Codec, subtitleProfile.Format))
                {
                    info.Url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
                                             baseUrl,
                                             ItemId,
                                             MediaSourceId,
                                             StringHelper.ToStringCultureInvariant(stream.Index),
                                             StringHelper.ToStringCultureInvariant(startPositionTicks),
                                             subtitleProfile.Format);

                    if (!string.IsNullOrEmpty(accessToken))
                    {
                        info.Url += "?api_key=" + accessToken;
                    }

                    info.IsExternalUrl = false;
                }
                else
                {
                    info.Url           = stream.Path;
                    info.IsExternalUrl = true;
                }
            }

            return(info);
        }