Erik
Erik

Reputation: 12140

Playing local files with HTML5

Is it possible to play a video file which users have stored locally on their computer on a website? The path of the file is not known to me, I want the users to choose the file with a "choose file" dialog.

The goal is to show overlays over the actual video files, but usually the video files will be too large to let the users upload them, such that I could process them on the server. So, I want the user to select the file from the local computer, directly play it with HTML5 in the browser and generate the overlays with Javascript.

Upvotes: 2

Views: 832

Answers (1)

Erik
Erik

Reputation: 12140

I found the solution. You can achieve this with the HTML5 File API:

var file = $('file')[0].files[0];
var url = window.URL.createObjectURL(file);
$('video')[0].src = url;

<input type="file" id="file" accept="video/*" />
<video controls autoplay></video>

Upvotes: 3

Related Questions