Reputation: 284
here is part of my code:
var myPlayer = document.getElementById("example_video_1");
if (content=="play()") {
$('title').html("screen:"+content);
myPlayer.play();
}
if (content=="pause()") {
$('title').html("screen:"+content);
myPlayer.pause();
}
if (content.indexOf("src(")!=-1) {
var videoMP4 = content.replace("src(","").replace(")","");
myPlayer.src({type: "video/mp4", src:videoMP4});
// {type: "video/webm", src:videoMP4.replace(".mp4", ".webm")},
// {type: "video/ogg", src:videoMP4.replace(".mp4", ".ogv")}
// ]
myPlayer.play();
}
the pause function and the play function work as expected. But for some reason when the code reaches the
myPlayer.src({type: "video/mp4", src:videoMP4});
i get an error in my console :
Uncaught TypeError: Property 'src' of object #<HTMLVideoElement> is not a function
any idea why this happens?
Upvotes: 2
Views: 6467
Reputation: 65509
Change the source and type like:
myPlayer.setAttribute("src", videoMP4);
myPlayer.setAttribute("type", "video/mp4");
myPlayer.load(); # Force video refresh...
Upvotes: 2
Reputation: 5530
src is a "DOMString", not a function.
See https://developer.mozilla.org/en-US/docs/DOM/HTMLMediaElement
Reflects the src HTML attribute, containing the URL of a media resource to use. Gecko implements a similar functionality is available for streams: mozSrcObject.
myPlayer.src = videoMP4;
If you want to specify multiple (typed) sources you need to create DOM elements as children of myPlayer.
Upvotes: 1
Reputation: 22536
var myPlayer = document.getElementById("example_video_1");
returns a standard HTML video
element. You need to use:
var myPlayer = _V_("example_video_1");
to get the VideoJS object.
Upvotes: 7