Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            services.AddOptions();
            services.Configure <PlayerSettings>(Configuration.GetSection("Settings"));
            var settings = Configuration.GetSection("Settings").Get <PlayerSettings>();


            // configure to use sqlite
            Dapper.SimpleCRUD.SetDialect(Dapper.SimpleCRUD.Dialect.SQLite);

            // make sure databases exist
            EnsureDatabasesExist(settings);

            // scan for files
            MusicScanner.Scan(settings, false);

            // setup last fm manager
            LastFMManager lastFMManager = new LastFMManager(settings);

            services.AddSingleton <LastFMManager>(lastFMManager);

            // load default playlist
            using (DAL.DALManager mgr = new DAL.DALManager(settings.DatabasePath))
            {
                var tracks = mgr.GetTrackItems(Domain.Objects.Playlist.ALL_ID);
                Player.Instance.LoadPlaylist(new Player.Playlist()
                {
                    Id     = Domain.Objects.Playlist.ALL_ID,
                    Tracks = tracks
                });
            }
        }
 public PlayerController(IOptions <PlayerSettings> settings, LastFMManager lastFmManager)
 {
     this.settings      = settings;
     this.lastFmManager = lastFmManager;
 }