Exemplo n.º 1
0
        public GoogleMusicWebService(
            IDependencyResolverContainer container,
            ILogManager logManager,
            IGoogleMusicSessionService sessionService)
        {
            var httpClientHandler = new HttpClientHandler
            {
                UseCookies        = false,
                AllowAutoRedirect = false
            };

            this.httpClient = new HttpClient(httpClientHandler)
            {
                BaseAddress           = new Uri(OriginUrl),
                Timeout               = TimeSpan.FromSeconds(90),
                DefaultRequestHeaders =
                {
                    { HttpRequestHeader.UserAgent.ToString(), "Music Manager (1, 0, 54, 4672 - Windows)" }
                }
            };

            this.container      = container;
            this.sessionService = sessionService;

            this.logger = logManager.CreateLogger("GoogleMusicWebService");
        }
Exemplo n.º 2
0
 public PlayerViewPresenter(
     IMediaElementContainer mediaElementContainer,
     IGoogleMusicSessionService sessionService,
     IPlayQueueService queueService,
     INavigationService navigationService,
     PlayerBindingModel playerBindingModel)
     : base(mediaElementContainer, sessionService, queueService, navigationService, playerBindingModel)
 {
     this.ShowMoreCommand = new DelegateCommand(() => this.MainFrame.ShowPopup <IPlayerMorePopupView>(PopupRegion.AppToolBarRight));
 }
Exemplo n.º 3
0
 public SongsWebService(
     IGoogleMusicWebService googleMusicWebService,
     IGoogleMusicSessionService sessionService,
     ISettingsService settingsService,
     ILogManager logManager)
 {
     this.googleMusicWebService = googleMusicWebService;
     this.sessionService        = sessionService;
     this.settingsService       = settingsService;
     this.logger = logManager.CreateLogger("SongsWebService");
 }
Exemplo n.º 4
0
        public LinksRegionViewPresenter(
            IApplicationStateService stateService,
            IApplicationResources resources,
            ISearchService searchService,
            IDispatcher dispatcher,
            IGoogleMusicSynchronizationService googleMusicSynchronizationService,
            IApplicationSettingViewsService applicationSettingViewsService,
            IGoogleMusicSessionService sessionService,
            INavigationService navigationService)
        {
            this.stateService = stateService;
            this.resources    = resources;
            this.dispatcher   = dispatcher;
            this.googleMusicSynchronizationService = googleMusicSynchronizationService;
            this.sessionService          = sessionService;
            this.navigationService       = navigationService;
            this.ShowSearchCommand       = new DelegateCommand(searchService.Activate);
            this.NavigateToDownloadQueue = new DelegateCommand(async() =>
            {
                if (!this.disableClickToCache)
                {
                    await this.dispatcher.RunAsync(() => applicationSettingViewsService.Show("offlinecache"));
                }
            });

            this.UpdateLibraryCommand = new DelegateCommand(
                async() =>
            {
                if (this.UpdateLibraryCommand.CanExecute())
                {
                    this.synchronizationTimer.Stop();
                    await this.Synchronize(forceToDownloadPlaylists: true);
                }
            },
                () => !this.BindingModel.ShowProgressRing);

            this.BindingModel = new LinksRegionBindingModel();

            this.synchronizationTimer = new DispatcherTimer {
                Interval = TimeSpan.FromMinutes(5)
            };
            this.synchronizationTimer.Stop();
            this.synchronizationTime = 0;

            this.synchronizationTimer.Tick += this.SynchronizationTimerOnTick;

            this.Logger.LogTask(this.Synchronize());

            this.SetOfflineMessageIfRequired();

            this.sessionService.SessionCleared += this.SessionServiceOnSessionCleared;
        }
Exemplo n.º 5
0
 public AuthentificationService(
     IApplicationResources resources,
     ILogManager logManager,
     IGoogleAccountService googleAccountService,
     IGoogleMusicSessionService sessionService,
     IGoogleAccountWebService googleAccountWebService,
     IGoogleMusicWebService googleMusicWebService)
 {
     this.logger                  = logManager.CreateLogger("AuthentificationService");
     this.resources               = resources;
     this.googleAccountService    = googleAccountService;
     this.sessionService          = sessionService;
     this.googleAccountWebService = googleAccountWebService;
     this.googleMusicWebService   = googleMusicWebService;
 }
Exemplo n.º 6
0
        public StartPageViewPresenter(
            IApplicationResources resources,
            ISettingsService settingsService,
            IAuthentificationService authentificationService,
            INavigationService navigationService,
            IPlayQueueService playQueueService,
            IPlaylistsService playlistsService,
            IMainFrameRegionProvider mainFrameRegionProvider,
            IGoogleMusicSessionService sessionService,
            ISearchService searchService,
            ISongsCachingService cachingService,
            IApplicationStateService stateService)
        {
            this.resources               = resources;
            this.settingsService         = settingsService;
            this.authentificationService = authentificationService;
            this.playQueueService        = playQueueService;
            this.navigationService       = navigationService;
            this.playlistsService        = playlistsService;
            this.mainFrameRegionProvider = mainFrameRegionProvider;
            this.sessionService          = sessionService;
            this.searchService           = searchService;
            this.cachingService          = cachingService;
            this.stateService            = stateService;

            Func <bool> canExecute = () => this.BindingModel.SelectedItems.Count > 0 &&
                                     this.BindingModel.SelectedItems.All(x =>
                                                                         x.Playlist.PlaylistType != PlaylistType.Radio ||
                                                                         (x.Playlist.PlaylistType == PlaylistType.UserPlaylist && !((UserPlaylist)x.Playlist).IsShared));

            this.PlayCommand     = new DelegateCommand(this.Play);
            this.QueueCommand    = new DelegateCommand(this.Queue, canExecute);
            this.DownloadCommand = new DelegateCommand(this.Download, canExecute);
            this.UnPinCommand    = new DelegateCommand(this.UnPin, canExecute);

            this.sessionService.SessionCleared += async(sender, args) =>
            {
                await this.DeinitializeAsync();

                this.ShowAuthentificationPopupView();
            };
        }
Exemplo n.º 7
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(); });
        }
Exemplo n.º 8
0
        public GoogleMusicApisService(
            ILogManager logManager,
            IGoogleMusicSessionService sessionService)
        {
            var httpClientHandler = new HttpClientHandler
            {
                UseCookies             = false,
                AllowAutoRedirect      = false,
                AutomaticDecompression = DecompressionMethods.GZip
            };

            this.httpClient = new HttpClient(httpClientHandler)
            {
                BaseAddress = new Uri(OriginUrl),
                Timeout     = TimeSpan.FromSeconds(90)
            };

            this.sessionService = sessionService;

            this.logger = logManager.CreateLogger("GoogleMusicApisService");
        }
Exemplo n.º 9
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;
        }
Exemplo n.º 10
0
        public OfflineCacheViewPresenter(
            IApplicationStateService stateService,
            IAlbumArtCacheService albumArtCacheService,
            ISongsCachingService songsCachingService,
            OfflineCacheViewBindingModel bindingModel,
            ISongsCachingService cachingService,
            IGoogleMusicSessionService sessionService)
        {
            this.stateService         = stateService;
            this.albumArtCacheService = albumArtCacheService;
            this.songsCachingService  = songsCachingService;
            this.cachingService       = cachingService;
            this.sessionService       = sessionService;
            this.BindingModel         = bindingModel;

            this.BindingModel.IsLoading = true;

            this.ClearAlbumArtsCacheCommand = new DelegateCommand(this.ClearAlbumArtsCache, () => this.sessionService.GetSession().IsAuthenticated&& !this.BindingModel.IsLoading);
            this.ClearSongsCacheCommand     = new DelegateCommand(this.ClearSongsCache, () => this.sessionService.GetSession().IsAuthenticated&& !this.BindingModel.IsLoading);
            this.CancelTaskCommand          = new DelegateCommand(this.CancelTask, (e) => this.sessionService.GetSession().IsAuthenticated&& !this.BindingModel.IsLoading);
            this.StartDownloadCommand       = new DelegateCommand(this.StartDownload, () => this.sessionService.GetSession().IsAuthenticated&& !this.BindingModel.IsLoading && this.stateService.IsOnline() && !this.cachingService.IsDownloading() && !this.BindingModel.IsQueueEmpty);
        }
        public SnappedPlayerViewPresenter(
            IMediaElementContainer mediaElementContainer,
            IGoogleMusicSessionService sessionService,
            IPlayQueueService queueService,
            INavigationService navigationService,
            SnappedPlayerBindingModel snappedPlayerBindingModel)
            : base(mediaElementContainer, sessionService, queueService, navigationService, snappedPlayerBindingModel)
        {
            this.queueService = queueService;
            this.isRadio      = this.queueService.IsRadio;

            this.RepeatAllCommand =
                new DelegateCommand(
                    () => { },
                    () => this.queueService.State != QueueState.Busy && !this.isRadio);

            this.ShuffleCommand =
                new DelegateCommand(
                    () => { },
                    () => this.queueService.State != QueueState.Busy && !this.isRadio);

            this.AddToQueueCommand = new DelegateCommand(
                () =>
            {
                if (ApplicationView.TryUnsnap())
                {
                    navigationService.NavigateTo <IStartPageView>();
                }
            });

            this.queueService.StateChanged += async(sender, args) => await this.Dispatcher.RunAsync(async() =>
            {
                this.UpdateCommands();

                await this.View.ScrollIntoCurrentSongAsync();
            });
        }
Exemplo n.º 12
0
        public StartPageViewPresenter(
            IApplicationResources resources,
            ISettingsService settingsService,
            IAuthentificationService authentificationService,
            INavigationService navigationService,
            IPlayQueueService playQueueService,
            IPlaylistsService playlistsService,
            IMainFrameRegionProvider mainFrameRegionProvider,
            IGoogleMusicSessionService sessionService,
            ISearchService searchService,
            ISongsCachingService cachingService,
            IApplicationStateService stateService)
        {
            this.resources               = resources;
            this.settingsService         = settingsService;
            this.authentificationService = authentificationService;
            this.playQueueService        = playQueueService;
            this.navigationService       = navigationService;
            this.playlistsService        = playlistsService;
            this.mainFrameRegionProvider = mainFrameRegionProvider;
            this.sessionService          = sessionService;
            this.searchService           = searchService;
            this.cachingService          = cachingService;
            this.stateService            = stateService;

            this.PlayCommand     = new DelegateCommand(this.Play);
            this.QueueCommand    = new DelegateCommand(this.Queue, () => this.BindingModel.SelectedItems.Count > 0);
            this.DownloadCommand = new DelegateCommand(this.Download, () => this.BindingModel.SelectedItems.Count > 0);
            this.UnPinCommand    = new DelegateCommand(this.UnPin, () => this.BindingModel.SelectedItems.Count > 0);

            this.sessionService.SessionCleared += async(sender, args) =>
            {
                await this.DeinitializeAsync();

                this.ShowAuthentificationPopupView();
            };
        }
Exemplo n.º 13
0
        protected PlayerViewPresenterBase(
            IMediaElementContainer mediaElementContainer,
            IGoogleMusicSessionService sessionService,
            IPlayQueueService queueService,
            INavigationService navigationService,
            TPlayerBindingModel playerBindingModel)
        {
            this.mediaElement      = mediaElementContainer;
            this.sessionService    = sessionService;
            this.queueService      = queueService;
            this.navigationService = navigationService;

            this.BindingModel = playerBindingModel;

            this.SkipBackCommand  = new DelegateCommand(this.PreviousSong, () => !this.BindingModel.IsBusy && this.queueService.CanSwitchToPrevious());
            this.PlayCommand      = new DelegateCommand(async() => await this.PlayAsync(), () => !this.BindingModel.IsBusy && (this.BindingModel.State == QueueState.Stopped || this.BindingModel.State == QueueState.Paused));
            this.PauseCommand     = new DelegateCommand(async() => await this.PauseAsync(), () => !this.BindingModel.IsBusy && this.BindingModel.IsPlaying);
            this.SkipAheadCommand = new DelegateCommand(this.NextSong, () => !this.BindingModel.IsBusy && this.queueService.CanSwitchToNext());

            this.BindingModel.Subscribe(
                () => this.BindingModel.CurrentPosition,
                async(sender, args) =>
            {
                if (this.BindingModel.IsPlaying)
                {
                    double currentPosition = this.BindingModel.CurrentPosition;
                    if (Math.Abs(this.progressPosition - currentPosition) > 1)
                    {
                        await this.mediaElement.SetPositionAsync(TimeSpan.FromSeconds(currentPosition));
                    }
                }
            });

            this.mediaElement.PlayProgress += (sender, args) =>
            {
                if (this.BindingModel.IsPlaying)
                {
                    try
                    {
                        this.BindingModel.FreezeNotifications();
                        this.BindingModel.TotalSeconds    = args.Duration.TotalSeconds;
                        this.BindingModel.CurrentPosition = this.progressPosition = args.Position.TotalSeconds;
                    }
                    finally
                    {
                        this.BindingModel.UnfreezeNotifications();
                    }
                }
            };

            this.sessionService.SessionCleared += (sender, args) => this.Dispatcher.RunAsync(
                async() =>
            {
                // TODO: clear playlists
                await this.StopAsync();
            });

            this.queueService.DownloadProgress += this.CurrentSongStreamOnDownloadProgressChanged;
            this.queueService.QueueChanged     += (sender, args) => this.UpdateCommands();
            this.queueService.StateChanged     += async(sender, args) => await this.Dispatcher.RunAsync(
                () =>
            {
                if (args.State == QueueState.Busy || args.State == QueueState.Stopped)
                {
                    this.BindingModel.CurrentPosition = 0d;
                    this.BindingModel.TotalSeconds    = 1.0d;
                }

                this.BindingModel.CurrentSong = args.CurrentSong == null ? null : new SongBindingModel(args.CurrentSong);
                this.BindingModel.State       = args.State;
                this.UpdateCommands();
            });

            this.NavigateToQueueView = new DelegateCommand(() => this.navigationService.NavigateTo <ICurrentPlaylistPageView>(parameter: true));
        }