Пример #1
0
        public async Task Move(int updown)
        {
            _timer.Stop();

            // Calculate index position
            var sequence = _book.Sequence.Where(
                w => w.Filename == _playerInfo.CurrentFilename &&
                w.TCIn <= _playerInfo.Position.CurrentTC &&
                w.TCOut > _playerInfo.Position.CurrentTC).FirstOrDefault();

            if (sequence != null)
            {
                _playerInfo.Position.CurrentIndex = _book.Sequence.IndexOf(sequence);
            }

            var index = _playerInfo.Position.CurrentIndex;

            do
            {
                index += updown;
            } while (index > 0 && index < _book.Sequence.Count && _book.Sequence[index].Level > _playerInfo.Position.NavigationLevel);

            // adjust bounds
            if (index < 0)
            {
                index = 0;
                return;
            }
            else if (index > _book.Sequence.Count - 1)
            {
                index = _book.Sequence.Count - 1;
                return;
            }
            else
            {
                _playerInfo.Position.CurrentIndex = index;
                _playerInfo.Position.CurrentSOM   = _book.Sequence[index].SOM;
                _playerInfo.Position.CurrentTC    = _book.Sequence[index].TCIn;
                _playerInfo.Position.CurrentTitle = _book.Sequence[index].Title;

                ChapterUpdate?.Invoke(_book.Title, _playerInfo.Position.CurrentTitle);
                TimeCodeUpdate?.Invoke(
                    new TimeSpan()
                    .Add(TimeSpan.FromSeconds(_playerInfo.Position.CurrentSOM))
                    .Add(TimeSpan.FromSeconds(_playerInfo.Position.CurrentTC))
                    );
            }

            await CrossMediaManager.Current.Pause();

            if (_book.Sequence[index].Filename != _playerInfo.CurrentFilename)
            {
                _playerInfo.CurrentFilename = $"{_book.Sequence[index].Filename}";
                _fileChanged = true;
            }

            _timer.Start();

            SaveStatus();
        }
Пример #2
0
        private void Current_PositionChanged(object sender, MediaManager.Playback.PositionChangedEventArgs e)
        {
            if (_playerInfo != null)
            {
                if (CrossMediaManager.Current.State == MediaPlayerState.Playing)
                {
                    _playerInfo.Position.CurrentTC = e.Position.TotalSeconds;

                    TimeCodeUpdate?.Invoke(
                        new TimeSpan()
                        .Add(e.Position)
                        .Add(TimeSpan.FromSeconds(_playerInfo.Position.CurrentSOM))
                        );
                }
            }
        }