ADD VideoPlayer component and implement video fetching functionality
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.ddf.vodsystem.services;
|
||||
|
||||
import com.ddf.vodsystem.entities.Clip;
|
||||
import com.ddf.vodsystem.entities.JobStatus;
|
||||
import com.ddf.vodsystem.exceptions.JobNotFinished;
|
||||
import com.ddf.vodsystem.exceptions.JobNotFound;
|
||||
import com.ddf.vodsystem.entities.Job;
|
||||
import com.ddf.vodsystem.repositories.ClipRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -15,10 +17,12 @@ import java.io.File;
|
||||
public class DownloadService {
|
||||
|
||||
private final JobService jobService;
|
||||
private final ClipRepository clipRepository;
|
||||
|
||||
@Autowired
|
||||
public DownloadService(JobService jobService) {
|
||||
public DownloadService(JobService jobService, ClipRepository clipRepository) {
|
||||
this.jobService = jobService;
|
||||
this.clipRepository = clipRepository;
|
||||
}
|
||||
|
||||
public Resource downloadInput(String uuid) {
|
||||
@@ -46,4 +50,19 @@ public class DownloadService {
|
||||
File file = job.getOutputFile();
|
||||
return new FileSystemResource(file);
|
||||
}
|
||||
|
||||
public Resource downloadClip(Clip clip) {
|
||||
String path = clip.getVideoPath();
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
throw new JobNotFound("Clip file not found");
|
||||
}
|
||||
|
||||
return new FileSystemResource(file);
|
||||
}
|
||||
|
||||
public Resource downloadClip(Long id) {
|
||||
Clip clip = clipRepository.findById(id).orElseThrow(() -> new JobNotFound("Clip not found with id: " + id));
|
||||
return downloadClip(clip);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user