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.AddCors();
            services.AddMvc();
            services.AddOptions();
            services.Configure <FolderOptions>(x =>
            {
                var section       = Configuration.GetSection("FolderPaths");
                x.AudioFolderPath = HostingEnvironment.ContentRootPath + section.GetValue <string>("AudioFolderPath");
                x.VideoFolderPath = HostingEnvironment.ContentRootPath + section.GetValue <string>("VideoFolderPath");
            });
            services.Configure <AudioOptions>(Configuration.GetSection("AudioInfo"));
            services.Configure <VideoRestrictsOptions>(Configuration.GetSection("VideoRestricts"));

            services.AddDbContext <PlayCatDbContext>(options =>
                                                     options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection")));

            ServiceProvider.RegisterServices(services);

            //Linux
            FFmpegConfig.FFmpegPath = "/usr/bin/ffmpeg";

            //Windows
            //FFmpegConfig.FFmpegPath = @"E:\Downloads\ffmpeg-20180720-3870ed7-win64-static\bin\ffmpeg.exe";

            //Mac OS
            //FFmpegConfig.FFmpegPath = @"/Users/admin/Documents/ffmpeg";

            services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info {
                    Title = "My API", Version = "v1"
                }); });
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();
            services.AddOptions();
            services.Configure <FolderOptions>(x =>
            {
                IConfigurationSection section = Configuration.GetSection("FolderPaths");
                x.AudioFolderPath             = HostingEnvironment.ContentRootPath + section.GetValue <string>("AudioFolderPath");
                x.VideoFolderPath             = HostingEnvironment.ContentRootPath + section.GetValue <string>("VideoFolderPath");
            });
            services.Configure <AudioOptions>(Configuration.GetSection("AudioInfo"));
            services.Configure <VideoRestrictsOptions>(Configuration.GetSection("VideoRestricts"));

            var connectionString = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContext <PlayCatDbContext>(options => options.UseNpgsql(connectionString));

            ServiceProvider.RegisterServices(services);

            FFmpegConfig.FFmpegPath = @"E:\Downloads\ffmpeg-20180720-3870ed7-win64-static\bin\ffmpeg.exe";
        }