public async void StartRadioStation() { using (var service = CreateCollectionSqlService()) { _station = await service.SelectFirstAsync <RadioStation>(p => p.Id == RadioId); if (_station == null) { return; } // Create the station manager var radioStationManager = new RadioStationManager(_station.GracenoteId, _station.Id, CreateCollectionSqlService, CreatePlayerSqlService); // Load tracks and add them to the database await radioStationManager.LoadTracksAsync(); await radioStationManager.UpdateQueueAsync(); OnEvent(QueueUpdated); _appSettingsHelper.Write(PlayerConstants.CurrentTrack, radioStationManager.QueueSongs[0].Id); StartRadioTrack(radioStationManager.QueueSongs[0]); } }
public async void StartRadioTrack(QueueSong track) { if (track == null) { return; } switch (track.Song.SongState) { case SongState.BackgroundMatching: _transportControls.IsPlayEnabled = false; _transportControls.IsNextEnabled = false; _transportControls.IsPreviousEnabled = false; OnEvent(MatchingTrack); // Create the station manager var radioStationManager = new RadioStationManager(_station.GracenoteId, _station.Id, CreateCollectionSqlService, CreatePlayerSqlService); var matched = await radioStationManager.MatchSongAsync(track.Song); _transportControls.IsNextEnabled = true; if (!matched) { SkipToNext(); return; } break; case SongState.NoMatch: SkipToNext(); break; } InternalStartTrack(track); }
public async void StartTrack(QueueSong track, bool ended = false) { if (track == null) return; try { ScrobbleOnMediaEnded(); } catch { } if (IsRadioMode && _station != null && _currentTrack != null && _currentTrack.Song.ProviderId.Contains("gn.")) { // Create the station manager var radioStationManager = new RadioStationManager(_station.GracenoteId, _station.Id, CreateCollectionSqlService, CreatePlayerSqlService); var trackId = _currentTrack.Song.ProviderId.Replace("gn.", ""); if (!ended) await radioStationManager.SkippedAsync(trackId); else await radioStationManager.PlayedAsync(trackId); await radioStationManager.UpdateQueueAsync(); track = radioStationManager.QueueSongs[0]; _appSettingsHelper.Write(PlayerConstants.CurrentTrack, track.Id); OnEvent(QueueUpdated); } _currentTrack = track; UpdateTile(); if (TrackChanged != null) OnTrackChanged(_currentTrack.SongId); _mediaPlayer.Pause(); if (_mediaPlayer.Position > TimeSpan.Zero) _mediaPlayer.Position = TimeSpan.Zero; _transportControls.PlaybackStatus = MediaPlaybackStatus.Changing; if (IsRadioMode) StartRadioTrack(track); else InternalStartTrack(track); }
public async void StartRadioTrack(QueueSong track) { if (track == null) return; switch (track.Song.SongState) { case SongState.BackgroundMatching: _transportControls.IsPlayEnabled = false; _transportControls.IsNextEnabled = false; _transportControls.IsPreviousEnabled = false; OnEvent(MatchingTrack); // Create the station manager var radioStationManager = new RadioStationManager(_station.GracenoteId, _station.Id, CreateCollectionSqlService, CreatePlayerSqlService); var matched = await radioStationManager.MatchSongAsync(track.Song); _transportControls.IsNextEnabled = true; if (!matched) { SkipToNext(); return; } break; case SongState.NoMatch: SkipToNext(); break; } InternalStartTrack(track); }
public async void StartRadioStation() { using (var service = CreateCollectionSqlService()) { _station = await service.SelectFirstAsync<RadioStation>(p => p.Id == RadioId); if (_station == null) return; // Create the station manager var radioStationManager = new RadioStationManager(_station.GracenoteId, _station.Id, CreateCollectionSqlService, CreatePlayerSqlService); // Load tracks and add them to the database await radioStationManager.LoadTracksAsync(); await radioStationManager.UpdateQueueAsync(); OnEvent(QueueUpdated); _appSettingsHelper.Write(PlayerConstants.CurrentTrack, radioStationManager.QueueSongs[0].Id); StartRadioTrack(radioStationManager.QueueSongs[0]); } }
public async void StartTrack(QueueSong track, bool ended = false) { if (track == null) { return; } try { ScrobbleOnMediaEnded(); } catch { } if (IsRadioMode && _station != null && _currentTrack != null && _currentTrack.Song.ProviderId.Contains("gn.")) { // Create the station manager var radioStationManager = new RadioStationManager(_station.GracenoteId, _station.Id, CreateCollectionSqlService, CreatePlayerSqlService); var trackId = _currentTrack.Song.ProviderId.Replace("gn.", ""); if (!ended) { await radioStationManager.SkippedAsync(trackId); } else { await radioStationManager.PlayedAsync(trackId); } await radioStationManager.UpdateQueueAsync(); track = radioStationManager.QueueSongs[0]; _appSettingsHelper.Write(PlayerConstants.CurrentTrack, track.Id); OnEvent(QueueUpdated); } _currentTrack = track; UpdateTile(); if (TrackChanged != null) { OnTrackChanged(_currentTrack.SongId); } _mediaPlayer.Pause(); if (_mediaPlayer.Position > TimeSpan.Zero) { _mediaPlayer.Position = TimeSpan.Zero; } _transportControls.PlaybackStatus = MediaPlaybackStatus.Changing; if (IsRadioMode) { StartRadioTrack(track); } else { InternalStartTrack(track); } }