Esempio n. 1
0
        public LastfmAuthentificationPresenter(
            IApplicationResources resources,
            ILastfmAccountWebService accountWebService,
            ICurrentSongPublisherService publisherService)
        {
            this.resources         = resources;
            this.accountWebService = accountWebService;
            this.publisherService  = publisherService;
            this.BindingModel      = new LastfmAuthentificationBindingModel
            {
                IsLoading = true,
                Message   = this.resources.GetString("LastFmAuthentification_Instruction")
            };

            this.accountWebService.GetTokenAsync().ContinueWith(
                t =>
            {
                if (t.IsCompleted && !t.IsFaulted && string.IsNullOrEmpty(t.Result.Error) &&
                    !string.IsNullOrEmpty(t.Result.Token))
                {
                    this.BindingModel.IsLoading = false;
                    var launchTask = Launcher.LaunchUriAsync(new Uri(this.BindingModel.LinkUrl = this.accountWebService.GetAuthUrl(this.token = t.Result.Token)));
                }
            },
                TaskScheduler.FromCurrentSynchronizationContext());
        }
Esempio n. 2
0
        public PlayQueueService(
            ILogManager logManager,
            IMediaElementContainer mediaElement,
            ISettingsService settingsService,
            ISongsCachingService songsCachingService,
            ICurrentSongPublisherService publisherService,
            IGoogleMusicSessionService sessionService,
            IPlaylistsService playlistsService,
            IRadioWebService radioWebService,
            IEventAggregator eventAggregator)
        {
            this.logger              = logManager.CreateLogger("PlayQueueService");
            this.mediaElement        = mediaElement;
            this.settingsService     = settingsService;
            this.songsCachingService = songsCachingService;
            this.publisherService    = publisherService;
            this.playlistsService    = playlistsService;
            this.radioWebService     = radioWebService;
            this.eventAggregator     = eventAggregator;
            this.currentQueueIndex   = -1;

            this.IsRepeatAll = this.settingsService.GetValue("IsRepeatAllEnabled", defaultValue: false);
            this.IsShuffled  = this.settingsService.GetValue("IsShuffleEnabled", defaultValue: false);

            this.State = QueueState.Unknown;

            this.mediaElement.MediaEnded += async(sender, args) =>
            {
                if (this.CanSwitchToNext())
                {
                    await this.NextSongAsync();
                }
                else
                {
                    this.State = QueueState.Stopped;
                }
            };

            sessionService.SessionCleared += async(sender, args) => { await ClearQueueAsync(); };
            eventAggregator.GetEvent <ReloadSongsEvent>().Subscribe(async(e) => { await ClearQueueAsync(); });
        }
Esempio n. 3
0
        public AccountsViewPresenter(
            IApplicationResources resources,
            IGoogleAccountService googleAccountService,
            IGoogleMusicSessionService sessionService,
            ILastfmWebService lastfmWebService,
            ICurrentSongPublisherService publisherService,
            IApplicationSettingViewsService applicationSettingViewsService,
            INavigationService navigationService)
        {
            this.resources                      = resources;
            this.googleAccountService           = googleAccountService;
            this.sessionService                 = sessionService;
            this.lastfmWebService               = lastfmWebService;
            this.publisherService               = publisherService;
            this.applicationSettingViewsService = applicationSettingViewsService;
            this.navigationService              = navigationService;
            this.BindingModel                   = new AccountViewBindingModel();
            this.ForgetAccountCommand           = new DelegateCommand(this.ForgetAccount);
            this.SignOutCommand                 = new DelegateCommand(this.SignOutAccount);
            this.LastfmUnlinkCommand            = new DelegateCommand(this.LastfmUnlink);
            this.LastfmLinkCommand              = new DelegateCommand(this.LastfmLink, () => this.sessionService.GetSession().IsAuthenticated);
            this.ReloadSongsCommand             = new DelegateCommand(this.ReloadSongs, () => this.navigationService.HasHistory());

            var userInfo = this.googleAccountService.GetUserInfo();

            if (userInfo != null)
            {
                this.BindingModel.AccountName  = userInfo.Email;
                this.BindingModel.IsRemembered = userInfo.RememberAccount;
            }

            Session lastfmSession = this.lastfmWebService.GetSession();

            if (lastfmSession != null)
            {
                this.BindingModel.LastfmAccountName = lastfmSession.Name;
            }

            this.BindingModel.HasSession = this.sessionService.GetSession().IsAuthenticated;
        }