Exemple #1
0
        internal static async Task <PlaylistItem> ToPlaylistItem(this BaseItemDto item, IApiClient apiClient, IPlaybackManager playbackManager)
        {
            var profile = VideoProfileHelper.GetWindowsPhoneProfile();
            var options = new AudioOptions
            {
                Profile      = profile,
                ItemId       = item.Id,
                DeviceId     = apiClient.DeviceId,
                MaxBitrate   = 128,
                MediaSources = item.MediaSources
            };

            var streamInfo = await playbackManager.GetAudioStreamInfo(App.ServerInfo.Id, options, false, apiClient);

            var streamUrl = streamInfo.ToUrl(apiClient.GetApiUrl("/"), apiClient.AccessToken);

            var converter = new Converters.ImageUrlConverter();

            return(new PlaylistItem
            {
                Album = item.Album,
                Artist = item.AlbumArtist,
                TrackName = item.Name,
                TrackUrl = streamUrl.Replace(App.ServerInfo.LocalAddress, !string.IsNullOrEmpty(App.ServerInfo.ManualAddress) ? App.ServerInfo.ManualAddress : App.ServerInfo.RemoteAddress),
                MediaBrowserId = item.Id,
                IsJustAdded = true,
                ImageUrl = (string)converter.Convert(item, typeof(string), null, null),
                BackgroundImageUrl = (string)converter.Convert(item, typeof(string), "backdrop", null),
                RunTimeTicks = item.RunTimeTicks ?? 0
            });
        }
        internal static PlaylistItem ToPlaylistItem(this BaseItemDto item, IApiClient apiClient)
        {
            var profile = VideoProfileHelper.GetWindowsPhoneProfile();
            var options = new AudioOptions
            {
                Profile = profile,
                ItemId = item.Id,
                DeviceId = apiClient.DeviceId,
                MaxBitrate = 128,
                MediaSources = item.MediaSources
            };

            var builder = new StreamBuilder();
            var streamInfo = builder.BuildAudioItem(options);

            var streamUrl = streamInfo.ToUrl(apiClient.GetApiUrl("/"), apiClient.AccessToken);

            var converter = new Converters.ImageUrlConverter();
            return new PlaylistItem
            {
                Album = item.Album,
                Artist = item.AlbumArtist,
                TrackName = item.Name,
                TrackUrl = streamUrl.Replace(App.ServerInfo.LocalAddress, !string.IsNullOrEmpty(App.ServerInfo.ManualAddress) ? App.ServerInfo.ManualAddress : App.ServerInfo.RemoteAddress),
                MediaBrowserId = item.Id,
                IsJustAdded = true,
                ImageUrl = (string) converter.Convert(item, typeof (string), null, null),
                BackgroundImageUrl = (string) converter.Convert(item, typeof (string), "backdrop", null),
                RunTimeTicks = item.RunTimeTicks ?? 0
            };
        }