Esempio n. 1
0
        private void ExecuteAddTrackStreamToFavorites(object parameter)
        {
            ITrackStream trackStream = parameter as ITrackStream;

            if (trackStream != null)
            {
                ExecuteAddTrackStreamDataToFavorites(trackStream.Data);
            }
        }
Esempio n. 2
0
        private void ExecutePlayTrackStream(object parameter)
        {
            ITrackStream trackStream = parameter as ITrackStream;

            if (trackStream != null)
            {
                Radio.Play(trackStream);
            }
        }
Esempio n. 3
0
        private void ExecuteQueueTrackStream(object parameter)
        {
            ITrackStream trackStream = parameter as ITrackStream;

            if (trackStream != null)
            {
                Radio.Queue(trackStream);
            }
        }
Esempio n. 4
0
        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);
        }
Esempio n. 6
0
        private void ExecutePlayTracks(IEnumerable tracks)
        {
            if (tracks == null)
            {
                return;
            }

            ITrackStream stream = tracks.OfType <Track>().ToTrackStream(CurrentArtist.Name);

            Radio.Play(stream);
        }
Esempio n. 7
0
        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
            });
        }
Esempio n. 8
0
        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;
                        });
                    }
                });
        }