Пример #1
0
        async void _device_MediaChanged(object sender, MediaChangedEventArgs e)
        {
            try
            {
                var streamInfo = StreamParams.ParseFromUrl(e.OldMediaInfo.Url, _libraryManager, _mediaSourceManager);
                if (streamInfo.Item != null)
                {
                    var progress = GetProgressInfo(e.OldMediaInfo, streamInfo);

                    var positionTicks = progress.PositionTicks;

                    ReportPlaybackStopped(e.OldMediaInfo, streamInfo, positionTicks);
                }

                streamInfo = StreamParams.ParseFromUrl(e.NewMediaInfo.Url, _libraryManager, _mediaSourceManager);
                if (streamInfo.Item == null)
                {
                    return;
                }

                var newItemProgress = GetProgressInfo(e.NewMediaInfo, streamInfo);

                await _sessionManager.OnPlaybackStart(newItemProgress).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error reporting progress", ex);
            }
        }
Пример #2
0
        async void _device_MediaChanged(object sender, MediaChangedEventArgs e)
        {
            try
            {
                var streamInfo = StreamParams.ParseFromUrl(e.OldMediaInfo.Url, _libraryManager);
                var progress = GetProgressInfo(e.OldMediaInfo, streamInfo);

                var positionTicks = progress.PositionTicks;

                ReportPlaybackStopped(e.OldMediaInfo, streamInfo, positionTicks);

                streamInfo = StreamParams.ParseFromUrl(e.NewMediaInfo.Url, _libraryManager);
                progress = GetProgressInfo(e.NewMediaInfo, streamInfo);

                await _sessionManager.OnPlaybackStart(progress).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error reporting progress", ex);
            }
        }