From f4b06fab22a2fc9256fe17240c28df9767837d34 Mon Sep 17 00:00:00 2001 From: Akshath Sai Pittala Date: Mon, 29 Jul 2024 23:10:49 +0530 Subject: [PATCH] - Major Overhaul in progress --- .../streamspace/www/StreamController.java | 17 +++++++++++++++++ src/main/resources/templates/player.html | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/akshathsaipittala/streamspace/www/StreamController.java b/src/main/java/com/akshathsaipittala/streamspace/www/StreamController.java index abc2034..b50cb7d 100644 --- a/src/main/java/com/akshathsaipittala/streamspace/www/StreamController.java +++ b/src/main/java/com/akshathsaipittala/streamspace/www/StreamController.java @@ -1,6 +1,9 @@ package com.akshathsaipittala.streamspace.www; +import com.akshathsaipittala.streamspace.library.VideoRepository; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; @@ -13,11 +16,25 @@ @Slf4j @Controller @RequestMapping("/stream") +@RequiredArgsConstructor public class StreamController { + final VideoRepository videoRepository; + @GetMapping("/video/{movieCode}") public String getVideoPlayer(@PathVariable("movieCode") String movieCode, Model model) { model.addAttribute("movieCode", movieCode); + var video = videoRepository.findById(URLDecoder.decode(movieCode, StandardCharsets.UTF_8)); + var contentMimeType = MediaType.APPLICATION_OCTET_STREAM_VALUE; + + // Workaround to get MKV Videos playing on Chromium browsers + if (video.get().getContentMimeType().equals("video/x-matroska")) { + contentMimeType = "video/webm"; + } else if (video.get().getContentMimeType().equals("video/mp4")) { + contentMimeType = "video/mp4"; + } + + model.addAttribute("contentMimeType", contentMimeType); return "player :: videoPlayer"; } diff --git a/src/main/resources/templates/player.html b/src/main/resources/templates/player.html index 1e3404e..9376024 100644 --- a/src/main/resources/templates/player.html +++ b/src/main/resources/templates/player.html @@ -2,9 +2,9 @@
-