private void ExecuteAddTrackStreamToFavorites(object parameter) { ITrackStream trackStream = parameter as ITrackStream; if (trackStream != null) { ExecuteAddTrackStreamDataToFavorites(trackStream.Data); } }
private void ExecutePlayTrackStream(object parameter) { ITrackStream trackStream = parameter as ITrackStream; if (trackStream != null) { Radio.Play(trackStream); } }
private void ExecuteQueueTrackStream(object parameter) { ITrackStream trackStream = parameter as ITrackStream; if (trackStream != null) { Radio.Queue(trackStream); } }
public void Play(ITrackStream trackStream) { _trackQueue = new ConcurrentQueue <Track>(); _dispatcher.BeginInvoke(new Action(_trackQueuePublic.Clear)); CurrentTrackStream = trackStream; try { if (_currentTokenSource != null && !_currentTokenSource.IsCancellationRequested) { _currentTokenSource.Cancel(); } } catch (Exception e) { _logger.Log(e.ToString(), Category.Exception, Priority.Low); } _currentTokenSource = new CancellationTokenSource(); var tct = _currentTokenSource.Token; Task .Factory .StartNew(() => { using (_loadingIndicatorService.EnterLoadingBlock()) { GetNextBatch(tct); _corePlayer.Stop(); while (!MoveToNextTrack()) { if (!GetNextBatch(tct)) { break; } } PeekToNextTrack(); } }, tct) .ContinueWith(task => { if (task.Exception != null) { task.Exception.Handle(e => { _toastService.Show("Error while playing track."); _logger.Log(e.ToString(), Category.Exception, Priority.High); return(true); }); } }); }
private void ExecutePlayTracks(IEnumerable tracks) { if (tracks == null) { return; } ITrackStream stream = tracks.OfType <Track>().ToTrackStream("Browsing"); Radio.Play(stream); }
private void ExecutePlayTracks(IEnumerable tracks) { if (tracks == null) { return; } ITrackStream stream = tracks.OfType <Track>().ToTrackStream(CurrentArtist.Name); Radio.Play(stream); }
private void ExecuteQueueTracks(IEnumerable tracks) { if (tracks == null) { return; } ITrackStream stream = tracks.OfType <Track>().ToTrackStream(CurrentArtist.Name); Radio.Queue(stream); ToastService.Show(new ToastData { Message = "Tracks queued", Icon = AppIcons.Add }); }
public void Queue(ITrackStream trackStream) { if (CurrentTrackStream == null) { _logger.Log("No track stream is already playing. Starting " + trackStream.Description, Category.Debug, Priority.Low); Play(trackStream); } else { _trackStreamQueue.Enqueue(trackStream); _logger.Log("Queued track stream " + trackStream.Description, Category.Debug, Priority.Low); _dispatcher.BeginInvoke(new Action <ITrackStream>(q => { _trackStreamQueuePublic.Add(q); OnTrackStreamQueued(); }), trackStream); } RaisePropertyChanged("CanGoToNextTrackStream"); }
private void ExecuteQueueTracks(IEnumerable tracks) { if (tracks == null) { return; } ITrackStream stream = tracks.OfType <Track>().ToTrackStream("Browsing"); Radio.Queue(stream); foreach (Track track in tracks) { Logger.Log("Queued " + track.Name, Category.Debug, Priority.Low); } ToastService.Show(new ToastData { Message = "Tracks queued", Icon = AppIcons.Add }); }
public void Queue(ITrackStream trackStream) { if (CurrentTrackStream == null) { _logger.Log("No track stream is already playing. Starting " + trackStream.Description, Category.Debug, Priority.Low); Play(trackStream); } else { _trackStreamQueue.Enqueue(trackStream); _logger.Log("Queued track stream " + trackStream.Description, Category.Debug, Priority.Low); _dispatcher.BeginInvoke(new Action<ITrackStream>(q => { _trackStreamQueuePublic.Add(q); OnTrackStreamQueued(); }), trackStream); } RaisePropertyChanged("CanGoToNextTrackStream"); }
public void Play(ITrackStream trackStream) { _trackQueue = new ConcurrentQueue<Track>(); _dispatcher.BeginInvoke(new Action(_trackQueuePublic.Clear)); CurrentTrackStream = trackStream; try { if (_currentTokenSource != null && !_currentTokenSource.IsCancellationRequested) { _currentTokenSource.Cancel(); } } catch (Exception e) { _logger.Log(e.ToString(), Category.Exception, Priority.Low); } _currentTokenSource = new CancellationTokenSource(); var tct = _currentTokenSource.Token; Task .Factory .StartNew(() => { using (_loadingIndicatorService.EnterLoadingBlock()) { GetNextBatch(tct); _corePlayer.Stop(); while (!MoveToNextTrack()) { if (!GetNextBatch(tct)) { break; } } PeekToNextTrack(); } }, tct) .ContinueWith(task => { if (task.Exception != null) { task.Exception.Handle(e => { _toastService.Show("Error while playing track."); _logger.Log(e.ToString(), Category.Exception, Priority.High); return true; }); } }); }