【问题标题】:Dailymotion iframe apiDailymotion iframe api
【发布时间】:2014-08-15 11:40:37
【问题描述】:

我正在使用 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>

http://jsfiddle.net/WpbJH/

但如果我将它直接嵌入 iframe 中,它就可以工作(它也会显示一些错误,但不是上面的错误):

<iframe src="http://www.dailymotion.com/embed/video/x1bpnpt?api=true&autoplay=1" width="640" height="360" frameborder="0"></iframe>

http://jsfiddle.net/MWhdC/

怎么了?

【问题讨论】:

  • 您好,您可以添加您在这两种情况下遇到的错误吗?它可能有助于人们理解。另外,您是在移动设备还是桌面设备上进行测试?
  • 当我测试您发送的两个 jsfiddle 链接时,一切似乎都运行良好(在第一种情况下,我还在控制台中看到了错误,但似乎不会影响视频播放)。你用的是哪个浏览器?

标签: dailymotion-api


【解决方案1】:

经过一番研究,我找到了导致此问题的原因。

他们使用的视频是来自第三方广告组的报告,需要向其报告视频的每一步。

上传自己的视频,并使用从中获得的 id,您会发现不会出现控制台错误。

希望对您有所帮助。

【讨论】:

    【解决方案2】:

    我正在查看,js文件没有正确加载,请查看 e.src = document.location.protocol + '//api.dmcdn.net/all.js';线

    document.location.protocol前缀域在//api.dmcdn.net/all.js前面。

    所以请看一下并告诉我。

    【讨论】:

      猜你喜欢
      • 2021-01-28
      • 1970-01-01
      • 2011-11-14
      • 1970-01-01
      • 1970-01-01
      • 2017-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多