admin管理员组文章数量:1290137
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?
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?
Share Improve this question asked Jan 9, 2013 at 14:55 tk66tk66 2847 silver badges21 bronze badges 1- myPlayer.src({ type: "video/mp4", src: "example./path/to/video.mp4" }); this is the example from the documentation site – tk66 Commented Jan 9, 2013 at 14:58
3 Answers
Reset to default 7var 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.
Change the source and type like:
myPlayer.setAttribute("src", videoMP4);
myPlayer.setAttribute("type", "video/mp4");
myPlayer.load(); # Force video refresh...
src is a "DOMString", not a function.
See https://developer.mozilla/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.
本文标签: javascriptvideojs src() function not recognizedStack Overflow
版权声明:本文标题:javascript - video.js .src() function not recognized - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741451129a2379494.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论