private PlayerPositionEntity RequestPosition(float positionPercentage) { try { // TODO: Move this into PlayerStatusPresenter //Console.WriteLine("LockScreenActivity - RequestPosition - positionPercentage: {0}", positionPercentage); // Calculate new position from 0.0f/1.0f scale long lengthBytes = _playerService.CurrentPlaylistItem.LengthBytes; var audioFile = _playerService.CurrentPlaylistItem.AudioFile; long positionBytes = (long)(positionPercentage * lengthBytes); //long positionBytes = (long)Math.Ceiling((double)Playlist.CurrentItem.LengthBytes * (percentage / 100)); long positionSamples = ConvertAudio.ToPCM(positionBytes, (uint)audioFile.BitsPerSample, audioFile.AudioChannels); int positionMS = (int)ConvertAudio.ToMS(positionSamples, (uint)audioFile.SampleRate); string positionString = Conversion.MillisecondsToTimeString((ulong)positionMS); PlayerPositionEntity entity = new PlayerPositionEntity(); entity.Position = positionString; entity.PositionBytes = positionBytes; entity.PositionSamples = (uint)positionSamples; return entity; } catch (System.Exception ex) { Console.WriteLine("LockScreenActivity - An error occured while calculating the player position: " + ex.Message); } return new PlayerPositionEntity(); }
public void RefreshPlayerPosition(PlayerPositionEntity entity) { if (_isPlayerPositionChanging || _isScrollViewWaveFormChangingSecondaryPosition) return; Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() => { lblPosition.Content = entity.Position; trackPosition.Value = (int)(entity.PositionPercentage * 10); scrollViewWaveForm.SetPosition(entity.PositionBytes); //Console.WriteLine("Player position: {0} {1} slider: {2} min: {3} max: {4}", entity.Position, entity.PositionPercentage, entity.PositionBytes, trackPosition.Minimum, trackPosition.Maximum); })); }
public void RefreshPlayerPosition(PlayerPositionEntity entity) { RunOnUiThread(() => { if (!_isPositionChanging) { _lblPosition.Text = entity.Position; _seekBar.Progress = (int) (entity.PositionPercentage * 100); } _waveFormScrollView.SetPosition(entity.PositionBytes); }); }
public void RefreshPlayerPosition(PlayerPositionEntity entity) { Gtk.Application.Invoke(delegate{ lblCurrentPosition.Text = entity.Position.ToString(); // Check if the user is currently changing the position if(!_isSongPositionChanging) hscaleSongPosition.Value = (double)(entity.PositionPercentage * 100); }); }
public void RefreshPlayerPosition(PlayerPositionEntity entity) { if (_isPlayerPositionChanging || _isScrollViewWaveFormChangingSecondaryPosition) return; InvokeOnMainThread(() => { lblPosition.StringValue = entity.Position; trackBarPosition.ValueWithoutEvent = (int)(entity.PositionPercentage * 10); waveFormScrollView.SetPosition(entity.PositionBytes); }); }
public void RefreshPlayerPosition(PlayerPositionEntity entity) { InvokeOnMainThread(() => { if(!_isPositionChanging) { lblPosition.Text = entity.Position; sliderPosition.SetPosition(entity.PositionPercentage * 100); } scrollViewWaveForm.SetPosition(entity.PositionBytes); }); }