Skip to content

Commit

Permalink
Add MIME type determination for video source
Browse files Browse the repository at this point in the history
element
  • Loading branch information
infinitel8p committed Nov 13, 2023
1 parent 423a717 commit 406204c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/public/js/playback.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ document.addEventListener('DOMContentLoaded', () => {
const container = document.querySelector('.video-grid');
videos.forEach(video => {
const videoElement = document.createElement('video');
videoElement.width = 320; // set your dimensions
videoElement.width = 320;
videoElement.height = 240;
videoElement.controls = true;

const sourceElement = document.createElement('source');
sourceElement.src = `recordings/${video}`;
sourceElement.type = 'video/mp4';

// Determine the MIME type based on file extension
const fileType = video.split('.').pop();
if (fileType === 'mp4') {
sourceElement.type = 'video/mp4';
} else if (fileType === 'h264') {
sourceElement.type = 'video/h264';
}

videoElement.appendChild(sourceElement);
container.appendChild(videoElement);
Expand Down

0 comments on commit 406204c

Please sign in to comment.