video playback and timeline playhead
This commit is contained in:
27
AZKiServer/Controllers/MediaController.cs
Normal file
27
AZKiServer/Controllers/MediaController.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using AZKiServer.Services;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using MongoDB.Bson;
|
||||
|
||||
namespace AZKiServer.Controllers;
|
||||
|
||||
[Route("/m/")]
|
||||
public class MediaController(MediaService mediaService, IConfiguration configuration) : Controller
|
||||
{
|
||||
private readonly string _basePath = configuration["SCAN_LOCATION"] ?? throw new NullReferenceException("SCAN_LOCATION is not set");
|
||||
|
||||
[HttpGet("v/{id}")]
|
||||
[ResponseCache(Duration = int.MaxValue)]
|
||||
public async Task<IActionResult> VideoAsync(ObjectId id)
|
||||
{
|
||||
var media = await mediaService.GetEntryAsync(id);
|
||||
if (media == null)
|
||||
return NotFound();
|
||||
if (media.Type != Models.MediaType.Video)
|
||||
return BadRequest();
|
||||
var filePath = Path.Combine(_basePath, media.Filepath);
|
||||
//var fs = new FileStream(, FileMode.Open);
|
||||
return PhysicalFile(filePath, "video/mp4", true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user