0% found this document useful (0 votes)
7 views1 page

Video Upload and Display Script

The document contains JavaScript code for handling video uploads and displaying a list of uploaded videos. It listens for a form submission, collects the title and video file, and sends them to the server via a POST request. Additionally, it fetches and displays the list of videos from the server, initializing them with Video.js for playback.

Uploaded by

anmolffbdaswdgr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Video Upload and Display Script

The document contains JavaScript code for handling video uploads and displaying a list of uploaded videos. It listens for a form submission, collects the title and video file, and sends them to the server via a POST request. Additionally, it fetches and displays the list of videos from the server, initializing them with Video.js for playback.

Uploaded by

anmolffbdaswdgr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

[Link]('uploadForm').

addEventListener('submit', async (e) => {


[Link]();
const formData = new FormData();
[Link]('title', [Link]('title').value);
[Link]('video', [Link]('videoFile').files[0]);

const response = await fetch('/upload', { method: 'POST', body: formData });


alert(await [Link]());
loadVideos();
});

async function loadVideos() {


const response = await fetch('/videos');
const videos = await [Link]();
const list = [Link]('videoList');
[Link] = '';
[Link](video => {
const div = [Link]('div');
[Link] = `
<h3>${[Link]}</h3>
<video class="video-js" controls>
<source src="${[Link]}" type="video/mp4">
</video>
`;
[Link](div);
});
// Initialize [Link]
videojs([Link]('.video-js'));
}

loadVideos();

You might also like