【问题标题】:Vimeo API not working for meVimeo API 不适合我
【发布时间】:2018-08-01 14:14:32
【问题描述】:

更新:vimeo api 是正确的。我的问题很愚蠢,这是一个缓存问题。我在 Chrome 中测试它并点击刷新,然后想.. 也许这只是一个缓存问题,所以我把它放在 IE 中并且它工作......然后回到 Chrome,清除缓存,它很好:) 谢谢大家为您的帮助...它可以帮助我讨论问题以便能够更清楚地看到问题:)

html 文件:

<body>

<iframe src="https://player.vimeo.com/video/15258975" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>


<script src="https://player.vimeo.com/api/player.js"></script>
<script src="https:/story_content/user.js"></script>

<script>
var iframe = document.querySelector('iframe');
var player = new Vimeo.Player(iframe);

player.on('play', function() {

    alert("yay!");
});

player.on('ended', function() {

    alert("ended!");
    myFunction1();
});     


var callback = function() {};

player.off('play', callback);   

var callback2 = function() {};

player.off('ended', callback2);


    </script>



</body>

这是我的 user.js 文件:

alert("where are you!1");


function myFunction1(){
    alert("where are you!2");
//alert("inside!!!function 1");

var player = window.parent.GetPlayer();

    //2. var test1 = player.GetVar("pie");

var test2 = player.SetVar("test1",100); 

   //2.  alert(test1);

   return test2;

}// User defined code goes here

第一个警报“你在哪里!1”运行,因此 html 正在调用我的 user.js 文件,但第二个警报:你在哪里!2 未运行,因此 myFunction1 未运行...然后我发出警报在 html 中的 Vimeo 代码中: player.on('play') 和 player.on(end') 并且它们不起作用。

但我知道 Vimeo API 正在工作,因为在我的旧 http 站点上它调用 myFunction...只是不在我迁移的新 https 站点上...

http://[takenOut]/Branch%20Manager%20-%20Action%20Plans%20-%20Storyline%20output/story_html5.html

https://[takenOut]/kristen/branchingTest/Branch%20Manager%20-%20Action%20Plans_v1%20-%20Storyline%20output/story_html5.html

感谢您的帮助。

【问题讨论】:

  • 您似乎正在尝试从 iframe 访问父 JS?
  • user.js url 中也有错误:https:/story_content/user.js 它缺少一个“/”
  • 你在哪里打电话 - myFunction1()?您将无法在您的 html 文件中访问它
  • 感谢您的回复。用户文件很好......我知道它从 html 连接很好,因为我的第一个警报弹出,所以我知道问题出在 API 中......但这是奇怪的部分。该 api 工作正常(在我的旧网站上仍然有效),但不在我的新网站上(player.on api 函数中的警报不起作用)。
  • Paul - myFunction1 在我的 user.js 文件中...我测试并确保正在调用 user.js 文件并且它是...所以我认为问题在于播放器.on 和 player.end 不工作。

标签: javascript api vimeo


【解决方案1】:

哦,不……我觉得自己很笨。这是一个兑现问题。感谢您对 Tanaydin 和 Paul Fitzgerald 的帮助。

【讨论】:

  • 这将有助于未来的读者编辑此答案并解释您为解决缓存问题所采取的步骤
  • “兑现”是指“缓存”吗?
  • 是的,抱歉,缓存。我在 Chrome 中测试它并点击刷新,然后想.. 也许这只是一个缓存问题,所以我把它放在 IE 中并且它工作......然后回到 Chrome,清除缓存,它很好:) 谢谢大家为您的帮助...它可以帮助我讨论问题以便能够更清楚地看到问题:)
猜你喜欢
  • 1970-01-01
  • 2016-10-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-11
相关资源
最近更新 更多