【问题标题】:Using Vimeo API and customize?使用 Vimeo API 并自定义?
【发布时间】:2015-01-12 08:23:46
【问题描述】:

我使用 Vimeo 的 API 主要是因为我想通过自己的按钮播放视频。

我遇到的唯一问题是,当我尝试将按钮内容(如 <button>Play</button> 更改为 <button>Play me</button>)时,视频无法播放。这是为什么呢?

拨弄here 看看我的意思。

来自 Vimeo 的 API 的 JS。

$(function() {
    var iframe = $('#player1')[0];
    var player = $f(iframe);
    var 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');
    }
});

【问题讨论】:

    标签: javascript api vimeo


    【解决方案1】:

    我解决了我自己的问题...

    我发现 API 正在寻找按钮内部的内容。在这种情况下:

    播放...

    所以我所做的是<button data-action="play">Play this video</button>

    在 JS 中我做了以下事情:

    $('button').bind("click", function() {
    
    player.api($(this).data("action"));
    
    });
    

    【讨论】:

      猜你喜欢
      • 2013-02-23
      • 1970-01-01
      • 1970-01-01
      • 2021-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多