private async Task OpenPlayable(IPlayable playable, IPlaylist playlist, bool openPlaying, bool openCrossfading, bool addToTempHistory) { _isOpeningTrack = true; if (CurrentTrack != null) { TrackChanged?.Invoke(this, new TrackChangedEventArgs(CurrentTrack, AudioEngine.TimePlaySourcePlayed)); } CurrentTrack = playable; CurrentPlaylist = playlist; if (await AudioEngine.OpenTrack(await playable.GetSoundSource(), IsCrossfadeEnabled && openCrossfading, 0)) { var track = playable as PlayableBase; if (track != null) { playlist?.GetBackHistory().Add(track); } NewTrackOpened?.Invoke(this, new NewTrackOpenedEventArgs(playable)); if (addToTempHistory && (_tempHistory.Count == 0 || _tempHistory.Last().Item1 != playlist || _tempHistory.Last().Item2 != playable)) { _tempHistory.Add(Tuple.Create(playlist, playable)); } if (openPlaying && !(IsCrossfadeEnabled && openCrossfading)) { await AudioEngine.TogglePlayPause(); } } _isOpeningTrack = false; }