Make video loading dynamic.
This commit is contained in:
@@ -28,7 +28,6 @@ pub async fn get_video_stream(
|
||||
) -> impl Responder {
|
||||
let video_result = video_service.get_video_stream(video_id.into_inner());
|
||||
|
||||
|
||||
match video_result {
|
||||
Ok(video) => {
|
||||
if let Some(tokio_video_file) = video.file.as_any().downcast_ref::<TokioVideoFile>() {
|
||||
@@ -39,11 +38,12 @@ pub async fn get_video_stream(
|
||||
Ok(file) => HttpResponse::Ok()
|
||||
.content_type("application/octet-stream")
|
||||
.streaming(async_stream::stream! {
|
||||
let mut stream = FramedRead::new(file, BytesCodec::new());
|
||||
while let Some(chunk) = stream.next().await {
|
||||
yield chunk.map(|bytes| bytes.freeze());
|
||||
}
|
||||
}),
|
||||
let file = tokio::fs::File::from_std(file);
|
||||
let mut stream = FramedRead::new(file, BytesCodec::new());
|
||||
while let Some(chunk) = stream.next().await {
|
||||
yield chunk.map(|bytes| bytes.freeze());
|
||||
}
|
||||
}),
|
||||
Err(_) => HttpResponse::InternalServerError().body("Failed to clone video file")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user