有人可以提供一个 vimeo 简单 api 工作示例(使用标准嵌入对象,而不是 froogaloop)吗?

发布于 2024-12-13 02:36:26 字数 1428 浏览 1 评论 0原文

Vimeo 文档相当糟糕。我无法触发简单的 api 就绪事件。 我研究了文档,但他们不清楚。我在论坛发帖,但答案不明确。 如果我使用普通的嵌入标签(在这种情况下我必须这样做),它应该自动触发 Ready 事件并监听默认的 vimeo_player_loaded() 函数。事实并非如此。或者至少它似乎没有这样做。

关于ready事件,文档明确指出:

“当播放器准备好接受命令时自动触发。在接收此事件之前不要尝试添加侦听器或调用函数。使用Flash嵌入代码时,播放器将尝试调用vimeo_player_loaded ()”。

所以????

顺便说一句,我的代码(视频正确嵌入但就绪回调未执行):

<script>
function vimeo_player_loaded(id){
//doesn't log anything because ready event seems to not fire
console.log(document.getElementById(id).api_play);
}
</script>

<object width="320" height="160">
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="flashvars" value="api=1" />
<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vimeo_id ?>&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" />
<embed src="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vimeo_id ?>&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" FlashVars="api=1" width="320" height="160"></embed>
</object>

Vimeo docs are quite poor. I cannot get the simple api ready event fired.
I studied the docs, but their not clear. I posted in forums, but answers are not clear.
If I use a normal embed tag (in this case I must do it), it should automatically fire the ready event and listen to a default vimeo_player_loaded() function. It doesn't. Or at least it doesn't seem to do that.

About the ready event, the docs clearly state:

"Fired automatically when the player is ready to accept commands. Do not try to add listeners or call functions before receiving this event. When using the Flash Embed Code, the player will attempt to call vimeo_player_loaded()."

So????

And by the way, my code (video correcly embedded but ready callback doesn't get executed):

<script>
function vimeo_player_loaded(id){
//doesn't log anything because ready event seems to not fire
console.log(document.getElementById(id).api_play);
}
</script>

<object width="320" height="160">
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="flashvars" value="api=1" />
<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vimeo_id ?>&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=ffffff&fullscreen=1&autoplay=0&loop=0" />
<embed src="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $vimeo_id ?>&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=ffffff&fullscreen=1&autoplay=0&loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" FlashVars="api=1" width="320" height="160"></embed>
</object>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情释 2024-12-20 02:36:26

终于做到了。所以我想分享:

<div style="width:320px; height:180px" id="flashbox-30861939"></div>
<script>
     //vimeo_player_loaded gets automatically called my the vimeo player
     //when it is ready
     function vimeo_player_loaded(id){
         //id is automatically passed
         var swfobj = document.getElementById(id);
         swfobj.api_play();//it works!!!
     }

     var swf = swfobject.embedSWF("http://vimeo.com/moogaloop.swf?clip_id=30861939&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=ffffff&fullscreen=1&autoplay=0&loop=0", "flashbox-30861939", "320", "180", "9.0.0","expressInstall.swf", { api:1, player_id:"flashbox-30861939" }, { allowfullscreen:true, allowscriptaccess:'always' });
</script>

所以,最后我使用了swfobject(请在调用上面的代码之前在页面中包含swfobject.js..)。

在传递正确的 ID 时应该非常小心。另外,请注意 flash vars:

{ api:1, player_id:"flashbox-30861939" }

和 params:

{ allowfullscreen:true, allowscriptaccess:'always' }

希望它有所帮助。
顺便说一句,当然,并不强制在 id 之后调用 swfobject.embedSWF。您可以像往常一样在文档的头部进行此操作。我这样做只是因为我的应用程序的一些要求。

Finally did. So I want to share:

<div style="width:320px; height:180px" id="flashbox-30861939"></div>
<script>
     //vimeo_player_loaded gets automatically called my the vimeo player
     //when it is ready
     function vimeo_player_loaded(id){
         //id is automatically passed
         var swfobj = document.getElementById(id);
         swfobj.api_play();//it works!!!
     }

     var swf = swfobject.embedSWF("http://vimeo.com/moogaloop.swf?clip_id=30861939&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=ffffff&fullscreen=1&autoplay=0&loop=0", "flashbox-30861939", "320", "180", "9.0.0","expressInstall.swf", { api:1, player_id:"flashbox-30861939" }, { allowfullscreen:true, allowscriptaccess:'always' });
</script>

So, in the end I used the swfobject (please include the swfobject.js in page before caling the code above..).

One should be quite carefull in passing the right ids. Also, pay attention to the flash vars:

{ api:1, player_id:"flashbox-30861939" }

and to the params:

{ allowfullscreen:true, allowscriptaccess:'always' }

Hope it helps.
By the way, of course, it's not mandatory to call swfobject.embedSWF AFTER the id. You can do it in the head of the doc as always. I do it there only due to some requirements of my app.

黯然 2024-12-20 02:36:26

另外,当将 Moogaloop 与 JQuery(我猜是 Mootools)一起使用时,请确保 vimeo_video_loaded() 方法位于 document.ready() 之外。 code> 脚本的一部分,否则不会被调用。

Also, when using Moogaloop together with JQuery (and I guess Mootools), make sure the vimeo_video_loaded() method is outside of the document.ready() part of the script, otherwise it will just not be called.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文