private async void Initialize() { // Media Foundation this.hasMediaFoundationSupport = MediaFoundationHelper.HasMediaFoundationSupport(); // Settings this.SetPlaybackSettings(); // PlayerFactory this.playerFactory = new PlayerFactory(); // Player (default for now, can be changed later when playing a file) this.player = this.playerFactory.Create(this.hasMediaFoundationSupport); // Audio device await this.SetAudioDeviceAsync(); // Equalizer await this.SetIsEqualizerEnabledAsync(SettingsClient.Get <bool>("Equalizer", "IsEnabled")); // Queued tracks this.GetSavedQueuedTracks(); }
protected override void RegisterTypes(IContainerRegistry containerRegistry) { RegisterCoreComponents(); RegisterFactories(); RegisterRepositories(); RegisterServices(); InitializeServices(); RegisterViews(); RegisterViewModels(); void RegisterCoreComponents() { containerRegistry.RegisterInstance <IContainerProvider>(Container); containerRegistry.RegisterInstance <ILocalizationInfo>(new LocalizationInfo()); } void RegisterFactories() { containerRegistry.RegisterSingleton <ISQLiteConnectionFactory, SQLiteConnectionFactory>(); } void RegisterRepositories() { containerRegistry.RegisterSingleton <IFolderRepository, FolderRepository>(); containerRegistry.RegisterSingleton <ITrackRepository, TrackRepository>(); containerRegistry.RegisterSingleton <IAlbumArtworkRepository, AlbumArtworkRepository>(); containerRegistry.RegisterSingleton <IQueuedTrackRepository, QueuedTrackRepository>(); containerRegistry.RegisterSingleton <IBlacklistTrackRepository, BlacklistTrackRepository>(); } void RegisterServices() { containerRegistry.RegisterSingleton <ICacheService, CacheService>(); containerRegistry.RegisterSingleton <IUpdateService, UpdateService>(); containerRegistry.RegisterSingleton <IAppearanceService, AppearanceService>(); containerRegistry.RegisterSingleton <II18nService, I18nService>(); containerRegistry.RegisterSingleton <IDialogService, DialogService>(); containerRegistry.RegisterSingleton <IIndexingService, IndexingService>(); containerRegistry.RegisterSingleton <IStatisticsService, StatisticsService>(); containerRegistry.RegisterSingleton <IPlaybackService, PlaybackService>(); containerRegistry.RegisterSingleton <IWin32InputService, Win32InputService>(); containerRegistry.RegisterSingleton <ISearchService, SearchService>(); containerRegistry.RegisterSingleton <ITaskbarService, TaskbarService>(); containerRegistry.RegisterSingleton <ICollectionService, CollectionService>(); containerRegistry.RegisterSingleton <IFoldersService, FoldersService>(); containerRegistry.RegisterSingleton <IJumpListService, JumpListService>(); containerRegistry.RegisterSingleton <IFileService, FileService>(); containerRegistry.RegisterSingleton <ICommandService, CommandService>(); containerRegistry.RegisterSingleton <IMetadataService, MetadataService>(); containerRegistry.RegisterSingleton <IEqualizerService, EqualizerService>(); containerRegistry.RegisterSingleton <IProviderService, ProviderService>(); containerRegistry.RegisterSingleton <IScrobblingService, ScrobblingService>(); containerRegistry.RegisterSingleton <IPlaylistService, PlaylistService>(); containerRegistry.RegisterSingleton <IExternalControlService, ExternalControlService>(); containerRegistry.RegisterSingleton <IWindowsIntegrationService, WindowsIntegrationService>(); containerRegistry.RegisterSingleton <ILyricsService, LyricsService>(); containerRegistry.RegisterSingleton <IShellService, ShellService>(); containerRegistry.RegisterSingleton <ILifetimeService, LifetimeService>(); containerRegistry.RegisterSingleton <IInfoDownloadService, InfoDownloadService>(); containerRegistry.RegisterSingleton <IRichPresenceService, RichPresenceService>(); containerRegistry.RegisterSingleton <IBlacklistService, BlacklistService>(); INotificationService notificationService; // NotificationService contains code that is only supported on Windows 10 if (Core.Base.Constants.IsWindows10 && MediaFoundationHelper.HasMediaFoundationSupport(true)) { // On some editions of Windows 10, constructing NotificationService still fails // (e.g. Windows 10 Enterprise N 2016 LTSB). Hence the try/catch block. try { notificationService = new NotificationService( Container.Resolve <IPlaybackService>(), Container.Resolve <ICacheService>(), Container.Resolve <IMetadataService>()); } catch (Exception ex) { LogClient.Error("Constructing NotificationService failed. Falling back to LegacyNotificationService. Exception: {0}", ex.Message); notificationService = new LegacyNotificationService( Container.Resolve <IPlaybackService>(), Container.Resolve <ICacheService>(), Container.Resolve <IMetadataService>()); } } else { notificationService = new LegacyNotificationService( Container.Resolve <IPlaybackService>(), Container.Resolve <ICacheService>(), Container.Resolve <IMetadataService>()); } containerRegistry.RegisterInstance(notificationService); } void InitializeServices() { // Making sure resources are set before we need them Container.Resolve <II18nService>().ApplyLanguageAsync(SettingsClient.Get <string>("Appearance", "Language")); Container.Resolve <IAppearanceService>().ApplyTheme(SettingsClient.Get <bool>("Appearance", "EnableLightTheme")); Container.Resolve <IAppearanceService>().ApplyColorSchemeAsync( SettingsClient.Get <string>("Appearance", "ColorScheme"), SettingsClient.Get <bool>("Appearance", "FollowWindowsColor"), SettingsClient.Get <bool>("Appearance", "FollowAlbumCoverColor") ); Container.Resolve <IExternalControlService>(); Container.Resolve <IRichPresenceService>(); } void RegisterViews() { // Misc. containerRegistry.Register <object, Oobe>(typeof(Oobe).FullName); containerRegistry.Register <object, TrayControls>(typeof(TrayControls).FullName); containerRegistry.Register <object, Shell>(typeof(Shell).FullName); containerRegistry.Register <object, Empty>(typeof(Empty).FullName); containerRegistry.Register <object, FullPlayer>(typeof(FullPlayer).FullName); containerRegistry.Register <object, CoverPlayer>(typeof(CoverPlayer).FullName); containerRegistry.Register <object, MicroPlayer>(typeof(MicroPlayer).FullName); containerRegistry.Register <object, NanoPlayer>(typeof(NanoPlayer).FullName); containerRegistry.Register <object, NowPlaying>(typeof(NowPlaying).FullName); containerRegistry.Register <object, WindowControls>(typeof(WindowControls).FullName); // Collection containerRegistry.Register <object, CollectionMenu>(typeof(CollectionMenu).FullName); containerRegistry.Register <object, Collection>(typeof(Collection).FullName); containerRegistry.Register <object, CollectionAlbums>(typeof(CollectionAlbums).FullName); containerRegistry.Register <object, CollectionArtists>(typeof(CollectionArtists).FullName); containerRegistry.Register <object, CollectionPlaylists>(typeof(CollectionPlaylists).FullName); containerRegistry.Register <object, CollectionFolders>(typeof(CollectionFolders).FullName); containerRegistry.Register <object, CollectionGenres>(typeof(CollectionGenres).FullName); containerRegistry.Register <object, CollectionTracks>(typeof(CollectionTracks).FullName); // Settings containerRegistry.Register <object, SettingsMenu>(typeof(SettingsMenu).FullName); containerRegistry.Register <object, Settings>(typeof(Settings).FullName); containerRegistry.Register <object, SettingsAppearance>(typeof(SettingsAppearance).FullName); containerRegistry.Register <object, SettingsBehaviour>(typeof(SettingsBehaviour).FullName); containerRegistry.Register <object, SettingsOnline>(typeof(SettingsOnline).FullName); containerRegistry.Register <object, SettingsPlayback>(typeof(SettingsPlayback).FullName); containerRegistry.Register <object, SettingsStartup>(typeof(SettingsStartup).FullName); containerRegistry.Register <object, SettingsBlacklist>(typeof(SettingsBlacklist).FullName); // Information containerRegistry.Register <object, InformationMenu>(typeof(InformationMenu).FullName); containerRegistry.Register <object, Information>(typeof(Information).FullName); containerRegistry.Register <object, InformationHelp>(typeof(InformationHelp).FullName); containerRegistry.Register <object, InformationAbout>(typeof(InformationAbout).FullName); // Now playing containerRegistry.Register <object, NowPlayingArtistInformation>(typeof(NowPlayingArtistInformation).FullName); containerRegistry.Register <object, NowPlayingLyrics>(typeof(NowPlayingLyrics).FullName); containerRegistry.Register <object, NowPlayingPlaylist>(typeof(NowPlayingPlaylist).FullName); containerRegistry.Register <object, NowPlayingShowcase>(typeof(NowPlayingShowcase).FullName); } void RegisterViewModels() { } }