最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Vimeo player api - play video with javascript - Stack Overflow

programmeradmin2浏览0评论

I'm trying to start playing video with javascript/jquery function. I copy example from vimeo site and upload it to the server, but it is not working.

<script type="text/javascript" src="/themes/js/froogaloop.js"></script>
<script type="text/javascript">
$(function(){
    var iframe = $('#player1')[0],
        player = $f(iframe),
        status = $('.status');

// When the player is ready, add listeners for pause, finish, and playProgress
    player.addEvent('ready', function() {
        status.text('ready');

        player.addEvent('pause', onPause);
        player.addEvent('finish', onFinish);
        player.addEvent('playProgress', onPlayProgress);
    });

  // Call the API when a button is pressed
    $('button').bind('click', function() {
        player.api($(this).text().toLowerCase());
    });

    function onPause(id) {
        status.text('paused');
    }

    function onFinish(id) {
        status.text('finished');
    }

    function onPlayProgress(data, id) {
        status.text(data.seconds + 's played');
    }


});
</script>

<iframe id="player1" src=";player_id=player1"   width="400" height="225" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>

<p>Video status: <span class="status">...</span></p>
<p><button>Play</button> <button>Pause</button></p>

On firefox I got message: "Content loading is blocked"

On safari buttons just do not work.

How to make it work?

I'm trying to start playing video with javascript/jquery function. I copy example from vimeo site and upload it to the server, but it is not working.

<script type="text/javascript" src="/themes/js/froogaloop.js"></script>
<script type="text/javascript">
$(function(){
    var iframe = $('#player1')[0],
        player = $f(iframe),
        status = $('.status');

// When the player is ready, add listeners for pause, finish, and playProgress
    player.addEvent('ready', function() {
        status.text('ready');

        player.addEvent('pause', onPause);
        player.addEvent('finish', onFinish);
        player.addEvent('playProgress', onPlayProgress);
    });

  // Call the API when a button is pressed
    $('button').bind('click', function() {
        player.api($(this).text().toLowerCase());
    });

    function onPause(id) {
        status.text('paused');
    }

    function onFinish(id) {
        status.text('finished');
    }

    function onPlayProgress(data, id) {
        status.text(data.seconds + 's played');
    }


});
</script>

<iframe id="player1" src="http://player.vimeo./video/27855315?api=1&player_id=player1"   width="400" height="225" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>

<p>Video status: <span class="status">...</span></p>
<p><button>Play</button> <button>Pause</button></p>

On firefox I got message: "Content loading is blocked"

On safari buttons just do not work.

How to make it work?

Share Improve this question asked Nov 6, 2013 at 12:25 TamaraTamara 2,9806 gold badges49 silver badges75 bronze badges 1
  • 3 As of 2016 Vimeo player has a new javascript API, frogaloop is not longer remended: github./vimeo/player.js/blob/master/README.md – PetaspeedBeaver Commented Dec 14, 2016 at 13:19
Add a ment  | 

1 Answer 1

Reset to default 2

You would need to make sure you're including the jQuery library for this code. Before the froogaloop script try adding:

<script src="//ajax.googleapis./ajax/libs/jquery/1.10.2/jquery.min.js"></script>

Here's a fiddle of it working http://jsfiddle/nkfH4/

发布评论

评论列表(0)

  1. 暂无评论