Bjorn
Bjorn

Reputation: 43

How can i switch the source for the VideoJS player?

I want to create a videoplayer in a browser, and be able to switch the source of the video. All the video's are stored on the computer.

I am trying to use VideoJS, an i got it working for 1 video, but i cannot get it to switch to a different video.

I would like to open an video from a location, for instance using:

<input type="file" id="files">

This would be the source for the player.

The source of the videojs is as follows, where i cannot use a variable.

<source src="video/example.mp4" type='video/mp4'>    

Anybody an idea?

I am fairly new to HTML5 and Javascript, and i don't know which termonolgy to use to find the answers.

Upvotes: 1

Views: 5119

Answers (1)

MartinW
MartinW

Reputation: 5041

First you get the instance of your player and then you set a new source (or new sources) via the Player.src function:

var player = videojs('my-player');
player.src({ type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" });

For more detailed information, have a look at the documentation of Player.src.

Upvotes: 3

Related Questions