我正在使用 dailymotion api 播放视频。示例直接来自文档:
http://www.dailymotion.com/doc/api/player.html#api-reference
它在控制台中给了我错误:
<!-- This <div> tag will be replaced the <iframe> video player -->
<div id="player"></div>
<script>
// This code loads the Dailymotion Javascript SDK asynchronously.
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//api.dmcdn.net/all.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(e, s);
}());
// This function init the player once the SDK is loaded
window.dmAsyncInit = function()
{
// PARAMS is a javascript object containing parameters to pass to the player if any (eg: {autoplay: 1})
var player = DM.player("player", {video: "x1bpnpt", width: "640", height: "360", params: {autoplay: 1}});
// 4. We can attach some events on the player (using standard DOM events)
player.addEventListener("apiready", function(e)
{
e.target.play();
});
};
</script>
但是如果我将它直接嵌入到 iframe 中,那么它就可以工作(它也会显示一些错误,但不是上面的错误):
<iframe src="http://www.dailymotion.com/embed/video/x1bpnpt?api=true&autoplay=1" width="640" height="360" frameborder="0"></iframe>
怎么了?