mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 21:06:30 +00:00
add controller for video
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Azaion.Repository\Azaion.Repository.csproj" />
|
||||
<ProjectReference Include="..\Azaion.Video\Azaion.Video.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using Azaion.Video;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Azaion.WebService.Controllers;
|
||||
|
||||
[Route("/controller")]
|
||||
[ApiController]
|
||||
public class VideoController(IVideoManager videoManager) : Controller
|
||||
{
|
||||
[HttpGet("{guid}")]
|
||||
public IActionResult GetVideo(Guid guid)
|
||||
{
|
||||
var media = videoManager.Get(guid);
|
||||
var fileStream = new FileStream(media.M3U8File, FileMode.Open);
|
||||
var fileSize = new FileInfo(media.Path).Length;
|
||||
Response.ContentLength = fileSize;
|
||||
return File(fileStream, "application/x-mpegURL", true);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
using Azaion.Repository;
|
||||
using Azaion.Repository.DTO;
|
||||
using Azaion.Video;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.Configure<ConnectionStrings>(builder.Configuration.GetSection(nameof(ConnectionStrings)));
|
||||
builder.Services.AddSingleton<IDbFactory, DbFactory>(sp => new DbFactory(sp.GetService<IOptions<ConnectionStrings>>()!.Value.FraudDb!));
|
||||
builder.Services.AddScoped<IVideoManager, VideoManager>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
@@ -20,29 +23,5 @@ if (app.Environment.IsDevelopment())
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
var summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
app.MapGet("/weatherforecast", () =>
|
||||
{
|
||||
var forecast = Enumerable.Range(1, 5).Select(index =>
|
||||
new WeatherForecast
|
||||
(
|
||||
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
Random.Shared.Next(-20, 55),
|
||||
summaries[Random.Shared.Next(summaries.Length)]
|
||||
))
|
||||
.ToArray();
|
||||
return forecast;
|
||||
})
|
||||
.WithName("GetWeatherForecast")
|
||||
.WithOpenApi();
|
||||
|
||||
app.MapControllers();
|
||||
app.Run();
|
||||
|
||||
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
||||
{
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
||||
Reference in New Issue
Block a user