void CheckPlaybackStatus(NSTimer timer) { if (CurrentSong == null || CurrentItem == null) { return; } if (Duration > 0 && Math.Abs(lastDurration) < Double.Epsilon) { Seek(Settings.CurrentPlaybackPercent); lastDurration = Duration; } if (State == PlaybackState.Paused || State == PlaybackState.Stopped) { return; } var time = player.CurrentTimeSeconds(); if (player.Rate > 0 && Math.Abs(time - lastSeconds) > Double.Epsilon) { lastSeconds = time; return; } if (checkPlaybackTask != null && !checkPlaybackTask.IsCompleted) { return; } checkPlaybackTask = Task.Run(async() => { if (player.Rate > 0) { await PrepareSong(CurrentSong, isVideo); player.Play(); if (time > 0) { player.Seek(time); } } else { Play(); } }); }
public async void Play() { #if __IOS__ silentPlayer.Play(); #endif if ((State == PlaybackState.Playing && player.Rate > 0 && player.CurrentItem.Tracks.Length > 0) || State == PlaybackState.Buffering || CurrentSong == null) { return; } if (player.CurrentItem != null && player.CurrentItem.Error == null && player.CurrentItem.Tracks.Length > 0) { ScrobbleManager.Shared.SetNowPlaying(CurrentSong, Settings.CurrentTrackId); player.Play(); Seek(Settings.CurrentPlaybackPercent); } else { await PlaySong(CurrentSong, isVideo); } }