Skip to content

Commit

Permalink
- Major Overhaul in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshathSai committed Jul 29, 2024
1 parent fd6d45e commit f4b06fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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";
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/player.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<div class="fade-me-in">
<!--<p class="display-6 text-muted">Now Playing</p>-->
<video class="img-fluid shadow-lg" controls preload="auto">
<source th:src="@{'/videos/' + ${movieCode} + '/content'}">
<source th:src="@{'/videos/' + ${movieCode}}" type="video/webm">
<video class="img-fluid shadow-lg" controls>
<source th:src="@{'/videos/' + ${movieCode} + '/content'}" th:type="${contentMimeType}">
<source th:src="@{'/videos/' + ${movieCode}}" th:type="${contentMimeType}">
</video>
</div>

Expand Down

0 comments on commit f4b06fa

Please sign in to comment.