コード例 #1
0
ファイル: PlayablePathBuilder.cs プロジェクト: TomGillen/MBT
        private static string GetStreamedPath(BaseItemDto item, IApiClient apiClient, long? startTimeTicks)
        {
            var extension = item.LocationType == LocationType.Remote ? null : Path.GetExtension(item.Path);

            if (item.IsAudio)
            {
                if (item.LocationType == LocationType.Remote)
                {
                    return apiClient.GetAudioStreamUrl(new StreamOptions
                    {
                        ItemId = item.Id,
                        OutputFileExtension = ".aac",
                        AudioCodec = "aac",
                        StartTimeTicks = startTimeTicks
                    });
                }

                return apiClient.GetAudioStreamUrl(new StreamOptions
                {
                    Static = true,
                    ItemId = item.Id,
                    OutputFileExtension = extension,
                    AudioCodec = "copy",
                    StartTimeTicks = startTimeTicks
                });
            }

            if (item.LocationType == LocationType.Remote)
            {
                return apiClient.GetVideoStreamUrl(new VideoStreamOptions
                {
                    ItemId = item.Id,
                    OutputFileExtension = "ts",
                    VideoCodec = "h264",
                    AudioCodec = "aac"
                });
            }

            // Folder rips
            if (item.VideoType.HasValue && item.VideoType.Value != VideoType.VideoFile)
            {
                return apiClient.GetVideoStreamUrl(new VideoStreamOptions
                {
                    ItemId = item.Id,
                    OutputFileExtension = "ts",
                    VideoCodec = "h264",
                    AudioCodec = "aac"
                });
            }

            return apiClient.GetVideoStreamUrl(new VideoStreamOptions
            {
                Static = true,
                ItemId = item.Id,
                OutputFileExtension = extension
            });
        }