protected PlaylistsPageViewPresenterBase(
            IApplicationResources resources,
            IPlaylistsService playlistsService,
            INavigationService navigationService,
            IPlayQueueService playQueueService,
            ISongsCachingService cachingService,
            IApplicationStateService stateService,
            IRadioStationsService radioStationsService,
            ISettingsService settingsService)
        {
            this.resources            = resources;
            this.playlistsService     = playlistsService;
            this.navigationService    = navigationService;
            this.playQueueService     = playQueueService;
            this.cachingService       = cachingService;
            this.stateService         = stateService;
            this.radioStationsService = radioStationsService;
            this.settingsService      = settingsService;

            Func <bool> canExecute = () => this.BindingModel.SelectedItems.Count > 0 &&
                                     this.BindingModel.SelectedItems.All(x => (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.StartRadioCommand = new DelegateCommand(this.StartRadio, () => this.BindingModel != null && this.BindingModel.SelectedItems.Count == 1);
        }
Example #2
0
        public PlayerMorePopupViewBindingModel(
            IMediaElementContainer mediaElementContainer,
            IPlayQueueService playQueueService,
            IEventAggregator eventAggregator,
            IApplicationStateService stateService,
            IApplicationResources applicationResources,
            IDispatcher dispatcher)
        {
            this.mediaElementContainer = mediaElementContainer;
            this.playQueueService      = playQueueService;
            this.eventAggregator       = eventAggregator;
            this.stateService          = stateService;
            this.applicationResources  = applicationResources;
            this.dispatcher            = dispatcher;

            this.RegisterForDispose(this.eventAggregator.GetEvent <QueueChangeEvent>().Subscribe(
                                        async(e) => await this.dispatcher.RunAsync(() =>
            {
                this.RaisePropertyChanged(() => this.IsShuffleEnabled);
                this.RaisePropertyChanged(() => this.IsRepeatAllEnabled);
            })));

            this.RegisterForDispose(this.eventAggregator.GetEvent <ApplicationStateChangeEvent>().Subscribe(
                                        async(e) => await this.dispatcher.RunAsync(() => this.RaisePropertyChanged(() => this.IsOnlineMode))));
        }
 public PlaylistsPageViewPresenter(
     IApplicationResources resources,
     IPlaylistsService playlistsService,
     INavigationService navigationService,
     IPlayQueueService playQueueService,
     ISongsCachingService cachingService,
     IApplicationStateService stateService)
     : base(resources, playlistsService, navigationService, playQueueService, cachingService, stateService)
 {
 }
 public MediaControlIntegration(
     ILogManager logManager,
     IPlayQueueService playQueueService,
     IDispatcher dispatcher)
 {
     this.logger           = logManager.CreateLogger("MediaControlIntegration");
     this.playQueueService = playQueueService;
     this.dispatcher       = dispatcher;
     this.playQueueService.StateChanged += this.StateChanged;
 }
Example #5
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));
 }
 public QueueActionsPopupViewPresenter(
     SelectedItems selectedItems,
     IPlayQueueService playQueueService,
     IPlaylistsService playlistsService)
 {
     this.selectedItems     = selectedItems;
     this.playQueueService  = playQueueService;
     this.playlistsService  = playlistsService;
     this.ShuffleAllCommand = new DelegateCommand(this.ShuffleAll);
     this.PlayCommand       = new DelegateCommand(this.Play);
     this.AddCommand        = new DelegateCommand(this.Add);
 }
        internal CurrentPlaylistPageViewPresenter(
            IApplicationResources resources,
            IPlayQueueService playQueueService,
            ISongsService metadataEditService,
            ISongsCachingService cachingService,
            IApplicationStateService stateService,
            INavigationService navigationService,
            IRadioStationsService radioStationsService,
            ISettingsService settingsService,
            SongsBindingModel songsBindingModel)
        {
            this.resources            = resources;
            this.playQueueService     = playQueueService;
            this.metadataEditService  = metadataEditService;
            this.cachingService       = cachingService;
            this.stateService         = stateService;
            this.navigationService    = navigationService;
            this.radioStationsService = radioStationsService;
            this.settingsService      = settingsService;
            this.BindingModel         = songsBindingModel;

            this.playQueueService.QueueChanged += async(sender, args) => await this.Dispatcher.RunAsync(this.UpdateSongs);

            //this.SaveAsPlaylistCommand = new DelegateCommand(this.SaveAsPlaylist, () => this.BindingModel.Songs.Count > 0);
            this.RemoveSelectedSongCommand = new DelegateCommand(this.RemoveSelectedSong, () => this.BindingModel.SelectedItems.Count > 0);
            this.AddToPlaylistCommand      = new DelegateCommand(this.AddToPlaylist, () => this.BindingModel.SelectedItems.Count > 0);
            this.RateSongCommand           = new DelegateCommand(this.RateSong);
            this.DownloadCommand           = new DelegateCommand(this.Download, () => this.BindingModel.SelectedItems.Count(x => !x.Metadata.UnknownSong) > 0);
            this.UnPinCommand      = new DelegateCommand(this.UnPin, () => this.BindingModel.SelectedItems.Count(x => !x.Metadata.UnknownSong) > 0);
            this.StartRadioCommand = new DelegateCommand(this.StartRadio, () => this.BindingModel != null && this.BindingModel.SelectedItems.Count == 1);

            this.playQueueService.StateChanged += async(sender, args) => await this.Dispatcher.RunAsync(async() =>
            {
                if (this.BindingModel.SelectedItems.Count == 0)
                {
                    if (this.BindingModel.Songs != null && args.CurrentSong != null)
                    {
                        var currentSong = this.BindingModel.Songs.FirstOrDefault(x => string.Equals(x.Metadata.SongId, args.CurrentSong.SongId, StringComparison.Ordinal));
                        if (currentSong != null)
                        {
                            await this.View.ScrollIntoCurrentSongAsync(currentSong);
                        }
                    }
                }
            });
        }
Example #8
0
 public RadioPageViewPresenter(
     IApplicationResources resources,
     IPlaylistsService playlistsService,
     INavigationService navigationService,
     IPlayQueueService playQueueService,
     ISongsCachingService cachingService,
     IApplicationStateService stateService,
     IRadioWebService radioWebService)
     : base(resources, playlistsService, navigationService, playQueueService, cachingService, stateService)
 {
     this.resources            = resources;
     this.navigationService    = navigationService;
     this.playQueueService     = playQueueService;
     this.radioWebService      = radioWebService;
     this.EditRadioNameCommand = new DelegateCommand(this.EditRadioName, () => this.BindingModel.SelectedItems.Count == 1);
     this.DeleteRadioCommand   = new DelegateCommand(this.DeleteRadio, () => this.BindingModel.SelectedItems.Count > 0);
 }
 public UserPlaylistsPageViewPresenter(
     IApplicationResources resources,
     INavigationService navigationService,
     IPlayQueueService playQueueService,
     IPlaylistsService playlistsService,
     IUserPlaylistsService userPlaylistsService,
     ISongsCachingService cachingService,
     IApplicationStateService stateService)
     : base(resources, playlistsService, navigationService, playQueueService, cachingService, stateService)
 {
     this.resources              = resources;
     this.userPlaylistsService   = userPlaylistsService;
     this.stateService           = stateService;
     this.AddPlaylistCommand     = new DelegateCommand(this.AddPlaylist);
     this.EditPlaylistCommand    = new DelegateCommand(this.EditPlaylist, () => this.BindingModel.SelectedItems.Count == 1);
     this.DeletePlaylistsCommand = new DelegateCommand(this.DeletePlaylists, () => this.BindingModel.SelectedItems.Count > 0);
 }
Example #10
0
        public PlaylistPageViewPresenterBase(IDependencyResolverContainer container)
        {
            this.playQueueService    = container.Resolve <IPlayQueueService>();
            this.metadataEditService = container.Resolve <ISongsService>();
            this.playlistsService    = container.Resolve <IPlaylistsService>();
            this.resources           = container.Resolve <IApplicationResources>();
            this.cachingService      = container.Resolve <ISongsCachingService>();
            this.stateService        = container.Resolve <IApplicationStateService>();
            this.radioWebService     = container.Resolve <IRadioWebService>();
            this.navigationService   = container.Resolve <INavigationService>();

            this.QueueCommand         = new DelegateCommand(this.Queue, () => this.BindingModel != null && this.BindingModel.SongsBindingModel.SelectedItems.Count > 0);
            this.AddToPlaylistCommand = new DelegateCommand(this.AddToPlaylist, () => this.BindingModel != null && this.BindingModel.SongsBindingModel.SelectedItems.Count > 0);
            this.DownloadCommand      = new DelegateCommand(this.Download, () => this.BindingModel != null && this.BindingModel.SongsBindingModel.SelectedItems.Count > 0);
            this.UnPinCommand         = new DelegateCommand(this.UnPin, () => this.BindingModel != null && this.BindingModel.SongsBindingModel.SelectedItems.Count > 0);
            this.RateSongCommand      = new DelegateCommand(this.RateSong);
            this.StartRadioCommand    = new DelegateCommand(this.StartRadio, () => this.BindingModel != null && this.BindingModel.SongsBindingModel.SelectedItems.Count == 1);
        }
 public RadioPageViewPresenter(
     IApplicationResources resources,
     IPlaylistsService playlistsService,
     INavigationService navigationService,
     IPlayQueueService playQueueService,
     ISongsCachingService cachingService,
     IApplicationStateService stateService,
     IRadioStationsService radioStationsService,
     ISettingsService settingsService)
     : base(resources, playlistsService, navigationService, playQueueService, cachingService, stateService, radioStationsService, settingsService)
 {
     this.resources            = resources;
     this.navigationService    = navigationService;
     this.playQueueService     = playQueueService;
     this.radioStationsService = radioStationsService;
     this.EditRadioNameCommand = new DelegateCommand(this.EditRadioName, () => this.BindingModel.SelectedItems.Count == 1);
     this.DeleteRadioCommand   = new DelegateCommand(this.DeleteRadio, () => this.BindingModel.SelectedItems.Count > 0 && this.BindingModel.SelectedItems.All(x => !string.IsNullOrEmpty(x.Playlist.Id)));
 }
        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();
            };
        }
Example #13
0
        protected PlaylistsPageViewPresenterBase(
            IApplicationResources resources,
            IPlaylistsService playlistsService,
            INavigationService navigationService,
            IPlayQueueService playQueueService,
            ISongsCachingService cachingService,
            IApplicationStateService stateService)
        {
            this.resources         = resources;
            this.playlistsService  = playlistsService;
            this.navigationService = navigationService;
            this.playQueueService  = playQueueService;
            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);
        }
Example #14
0
        public PlayerMorePopupViewPresenter(
            IPlayQueueService queueService,
            IApplicationSettingViewsService applicationSettingViewsService,
            PlayerMorePopupViewBindingModel bindingModel)
        {
            this.queueService = queueService;
            this.applicationSettingViewsService = applicationSettingViewsService;

            this.BindingModel = bindingModel;

            this.RepeatAllCommand = new DelegateCommand(() => { }, () => this.queueService.State != QueueState.Busy && !queueService.IsRadio);
            this.ShuffleCommand   = new DelegateCommand(() => { }, () => this.queueService.State != QueueState.Busy && !queueService.IsRadio);
            this.ShowApplicationSettingsCommand = new DelegateCommand(async() =>
            {
                await this.Dispatcher.RunAsync(
                    () => this.applicationSettingViewsService.Show());
            });

            this.queueService.StateChanged += this.QueueServiceOnStateChanged;
        }
Example #15
0
        public SnappedPlayerBindingModel(
            SongsBindingModel songsBindingModel,
            IMediaElementContainer mediaElementContainer,
            IPlayQueueService playQueueService,
            IEventAggregator eventAggregator,
            IDispatcher dispatcher)
        {
            this.mediaElementContainer = mediaElementContainer;
            this.playQueueService      = playQueueService;
            this.eventAggregator       = eventAggregator;
            this.dispatcher            = dispatcher;
            this.SongsBindingModel     = songsBindingModel;

            this.eventAggregator.GetEvent <QueueChangeEvent>().Subscribe(
                async(e) => await this.dispatcher.RunAsync(() =>
            {
                this.RaisePropertyChanged(() => this.IsShuffleEnabled);
                this.RaisePropertyChanged(() => this.IsRepeatAllEnabled);
            }));
        }
        internal ArtistPageViewPresenter(
            IApplicationResources resources,
            IPlayQueueService playQueueService,
            INavigationService navigationService,
            IPlaylistsService playlistsService,
            IAlbumsRepository albumsRepository,
            ISongsCachingService cachingService,
            IApplicationStateService stateService)
        {
            this.resources         = resources;
            this.playQueueService  = playQueueService;
            this.navigationService = navigationService;
            this.playlistsService  = playlistsService;
            this.albumsRepository  = albumsRepository;
            this.cachingService    = cachingService;
            this.stateService      = stateService;
            this.PlayCommand       = new DelegateCommand(this.Play);
            this.ShowAllCommand    = new DelegateCommand(this.ShowAll);

            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);
        }
        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();
            });
        }
        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();
            };
        }
Example #19
0
        public SongsBindingModel(
            IPlayQueueService playQueueService,
            IEventAggregator eventAggregator,
            IDispatcher dispatcher)
        {
            this.playQueueService = playQueueService;
            this.dispatcher       = dispatcher;
            this.Songs            = new ObservableCollection <SongBindingModel>();
            this.SortCommand      = new DelegateCommand(this.SortSongs);
            this.SelectedItems    = new ObservableCollection <SongBindingModel>();

            this.playQueueService.StateChanged += this.PlayQueueServiceOnStateChanged;

            eventAggregator.GetEvent <SongsUpdatedEvent>()
            .Subscribe(async(e) => await this.dispatcher.RunAsync(() => this.OnSongsUpdated(e.UpdatedSongs)));

            eventAggregator.GetEvent <SongCachingChangeEvent>()
            .Where(e => e.EventType == SongCachingChangeEventType.FinishDownloading || e.EventType == SongCachingChangeEventType.RemoveLocalCopy)
            .Subscribe(async(e) => await this.dispatcher.RunAsync(() => this.UpdateIfSongCached(e.Song, e.EventType)));

            eventAggregator.GetEvent <CachingChangeEvent>()
            .Where(e => e.EventType == SongCachingChangeEventType.ClearCache)
            .Subscribe(async(e) => await this.dispatcher.RunAsync(this.ClearAllIsCachedIcons));
        }
Example #20
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));
        }