Exemplo n.º 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
            });
        }
Exemplo n.º 2
0
        private async Task <StreamInfo> CreateVideoStream(string itemId, long startTimeTicks, List <MediaSourceInfo> mediaSources = null, bool useHls = false)
        {
            if (ForceHls)
            {
                useHls = true;
            }

            var profile = VideoProfileHelper.GetWindowsPhoneProfile(isHls: useHls);

            var streamingSettings = NavigationService.IsOnWifi
                ? App.SpecificSettings.WifiStreamingQuality.GetSettings()
                : App.SpecificSettings.StreamingQuality.GetSettings();

            var options = new VideoOptions
            {
                Profile      = profile,
                ItemId       = itemId,
                DeviceId     = ApiClient.DeviceId,
                MaxBitrate   = streamingSettings.VideoBitrate,
                MediaSources = mediaSources
            };

            try
            {
                var streamInfo = await _playbackManager.GetVideoStreamInfo(App.ServerInfo.Id, options, false, ApiClient);

                streamInfo.StartPositionTicks = startTimeTicks;

                return(streamInfo);
            }
            catch (PlaybackException pex)
            {
                Log.ErrorException("CreateVideoStream: " + pex.ErrorCode, pex);
                switch (pex.ErrorCode)
                {
                case PlaybackErrorCode.NoCompatibleStream:

                    break;

                case PlaybackErrorCode.NotAllowed:

                    break;

                case PlaybackErrorCode.RateLimitExceeded:

                    break;
                }
            }
            catch (Exception ex)
            {
                Log.ErrorException("CreateVideoStream", ex);
            }

            return(null);
        }
Exemplo n.º 3
0
        public static IConnectionManager CreateConnectionManager(IDevice device, ILogger logger, INetworkConnection networkConnection)
        {
            var manager = new ConnectionManager(
                logger,
                new CredentialProvider(),
                networkConnection,
                new ServerLocator(),
                "Windows Phone 8",
                ApplicationManifest.Current.App.Version,
                device,
                WindowsPhoneCapabilities.App(VideoProfileHelper.GetWindowsPhoneProfile()),
                new CryptographyProvider(),
                () => new WebSocketClient());

            return(manager);
        }