public IndexingService(
            ISQLiteConnectionFactory factory,
            ICacheService cacheService,
            IInfoDownloadService infoDownloadService,
            ITerminationService cancellationService,
            ITrackRepository trackRepository,
            IFolderRepository folderRepository,
            IAlbumArtworkRepository albumArtworkRepository)
        {
            this.cacheService        = cacheService;
            this.infoDownloadService = infoDownloadService;
            this.cancellationService = cancellationService;

            this.trackRepository         = trackRepository;
            this.folderRepository        = folderRepository;
            this.albumArtworkRepository  = albumArtworkRepository;
            this.sqliteConnectionFactory = factory;

            this.watcherManager = new FolderWatcherManager(this.folderRepository);
            this.cache          = new IndexerCache(this.sqliteConnectionFactory);

            SettingsClient.SettingChanged      += SettingsClient_SettingChanged;
            this.watcherManager.FoldersChanged += WatcherManager_FoldersChanged;

            this.isIndexing = false;
        }
Example #2
0
        public MetadataService(IPlaybackService playbackService, ICacheService cacheService, ITrackRepository trackRepository,
                               IAlbumArtworkRepository albumArtworkRepository)
        {
            this.playbackService        = playbackService;
            this.cacheService           = cacheService;
            this.trackRepository        = trackRepository;
            this.albumArtworkRepository = albumArtworkRepository;

            this.updater = new FileMetadataUpdater(this.playbackService, this.trackRepository);
        }
Example #3
0
        public CollectionFrequentViewModel(IContainerProvider container)
        {
            // Dependency injection
            this.playbackService        = container.Resolve <IPlaybackService>();
            this.cacheService           = container.Resolve <ICacheService>();
            this.indexingService        = container.Resolve <IIndexingService>();
            this.regionManager          = container.Resolve <IRegionManager>();
            this.trackRepository        = container.Resolve <ITrackRepository>();
            this.albumArtworkRepository = container.Resolve <IAlbumArtworkRepository>();

            // Events
            this.playbackService.PlaybackCountersChanged += async(_) => await this.PopulateAlbumHistoryAsync();

            this.indexingService.IndexingStopped += async(_, __) => await this.PopulateAlbumHistoryAsync();

            // Commands
            this.ClickCommand = new DelegateCommand <object>((albumViewModel) =>
            {
                try
                {
                    if (albumViewModel != null)
                    {
                        this.playbackService.EnqueueAlbumsAsync(new List <AlbumViewModel> {
                            (AlbumViewModel)albumViewModel
                        }, false, false);
                    }
                }
                catch (Exception ex)
                {
                    LogClient.Error("An error occurred during Album enqueue. Exception: {0}", ex.Message);
                }
            });

            this.LoadedCommand = new DelegateCommand(async() =>
            {
                if (!isFirstLoad)
                {
                    return;
                }

                isFirstLoad = false;

                await Task.Delay(Constants.CommonListLoadDelay);
                await this.PopulateAlbumHistoryAsync();
            });
        }
Example #4
0
        public IndexingService(ISQLiteConnectionFactory factory, ICacheService cacheService, ITrackRepository trackRepository,
                               IFolderRepository folderRepository, IFileMetadataFactory fileMetadataFactory, IAlbumArtworkRepository albumArtworkRepository)
        {
            this.cacheService           = cacheService;
            this.trackRepository        = trackRepository;
            this.folderRepository       = folderRepository;
            this.albumArtworkRepository = albumArtworkRepository;
            this.factory             = factory;
            this.fileMetadataFactory = fileMetadataFactory;

            this.watcherManager = new FolderWatcherManager(this.folderRepository);
            this.cache          = new IndexerCache(this.factory);

            SettingsClient.SettingChanged      += SettingsClient_SettingChanged;
            this.watcherManager.FoldersChanged += WatcherManager_FoldersChanged;

            this.isIndexing = false;
        }
        public AlbumsViewModelBase(IContainerProvider container) : base(container)
        {
            // Dependency injection
            this.container              = container;
            this.collectionService      = container.Resolve <ICollectionService>();
            this.playbackService        = container.Resolve <IPlaybackService>();
            this.dialogService          = container.Resolve <IDialogService>();
            this.searchService          = container.Resolve <ISearchService>();
            this.playlistService        = container.Resolve <IPlaylistService>();
            this.cacheService           = container.Resolve <ICacheService>();
            this.indexingService        = container.Resolve <IIndexingService>();
            this.albumArtworkRepository = container.Resolve <IAlbumArtworkRepository>();

            // Commands
            this.ToggleAlbumOrderCommand      = new DelegateCommand(() => this.ToggleAlbumOrder());
            this.ShuffleSelectedAlbumsCommand = new DelegateCommand(async() => await this.playbackService.EnqueueAlbumsAsync(this.SelectedAlbums, true, false));
            this.AddAlbumsToPlaylistCommand   = new DelegateCommand <string>(async(playlistName) => await this.AddAlbumsToPlaylistAsync(this.SelectedAlbums, playlistName));
            this.EditAlbumCommand             = new DelegateCommand(() => this.EditSelectedAlbum(), () => !this.IsIndexing);
            this.AddAlbumsToNowPlayingCommand = new DelegateCommand(async() => await this.AddAlbumsToNowPlayingAsync(this.SelectedAlbums));
            this.DelaySelectedAlbumsCommand   = new DelegateCommand(() => this.delaySelectedAlbums = true);

            // Events
            this.indexingService.AlbumArtworkAdded += async(_, e) => await this.RefreshAlbumArtworkAsync(e.AlbumKeys);

            this.SelectedAlbumsCommand = new DelegateCommand <object>(async(parameter) =>
            {
                if (this.delaySelectedAlbums)
                {
                    await Task.Delay(Constants.DelaySelectedAlbumsDelay);
                }

                this.delaySelectedAlbums = false;
                await this.SelectedAlbumsHandlerAsync(parameter);
            });

            this.SetCoverSizeCommand = new DelegateCommand <string>(async(coverSize) =>
            {
                if (int.TryParse(coverSize, out int selectedCoverSize))
                {
                    await this.SetCoversizeAsync((CoverSizeType)selectedCoverSize);
                }
            });
        }
Example #6
0
        public MetadataService(ICacheService cacheService, IPlaybackService playbackService, ITrackRepository trackRepository,
                               IAlbumArtworkRepository albumArtworkRepository, IFileMetadataFactory metadataFactory, IContainerProvider container)
        {
            this.cacheService    = cacheService;
            this.playbackService = playbackService;

            this.trackRepository        = trackRepository;
            this.albumArtworkRepository = albumArtworkRepository;
            this.metadataFactory        = metadataFactory;

            this.container = container;

            this.fileMetadataDictionary = new Dictionary <string, IFileMetadata>();

            this.updateFileMetadataTimer          = new Timer();
            this.updateFileMetadataTimer.Interval = this.updateFileMetadataLongTimeout;
            this.updateFileMetadataTimer.Elapsed += async(_, __) => await this.UpdateFileMetadataAsync();

            this.playbackService.PlaybackStopped += async(_, __) => await this.UpdateFileMetadataAsync();

            this.playbackService.PlaybackFailed += async(_, __) => await this.UpdateFileMetadataAsync();

            this.playbackService.PlaybackSuccess += async(_, __) => await this.UpdateFileMetadataAsync();
        }