Displaying videos directly from link from symfony cast website without downloading.

This commit is contained in:
Krzysztof Płaczek
2023-03-31 11:25:32 +02:00
parent dce3cdd929
commit 32ead90121
4 changed files with 21 additions and 7 deletions

View File

@@ -10,15 +10,17 @@ class ChapterController extends Controller
public function __invoke(Course $course, int $chapter, SymfonyCastDlService $symfonyCastDlService)
{
$chapter = $course->chapters->firstWhere('order', $chapter);
$symfonyCastDlService->videoSize($chapter);
if ($chapter->sync_offline) {
$symfonyCastDlService->downloadFile($chapter);
$videoUrl = $chapter->video_url;
} else {
$videoUrl = $symfonyCastDlService->getChapterInfo($chapter);
}
$chapters = $chapter->course->chapters;
$chapters = $chapter->course->chapters;
$next = $chapters->where('order', '>', $chapter->order)->first();
$prev = $chapters->where('order', '<', $chapter->order)->sortByDesc('order')->first();
return view('chapter.index', compact('chapter', 'chapters', 'prev', 'next'));
return view('chapter.index', compact('chapter', 'chapters', 'prev', 'next', 'videoUrl'));
}
}