示例#1
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);
        }