On iPhone, Vimeo Javascript API .play() function doesn't work until the video has been played

前端 未结 3 1928
死守一世寂寞
死守一世寂寞 2021-01-05 14:50

I\'m using SwipeView (http://cubiq.org/swipeview) to create a swipeable slideshow on touchscreen devices. This is simple enough with images, but I want to include a Vimeo vi

3条回答
  •  一整个雨季
    2021-01-05 15:18

    Safari remote console will show you the error on the console - Error: The viewer must initiate playback first.

    If you seek a video before it's played, the video won't start (iOS only; other platforms seem ok).

    player.addEvent('ready', function() {
        player.api("seekTo", 10);
    });
    

    So you need to do something like:

    if ( navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) {
        player.addEvent('play', function(id) {
            player.api("seekTo", 10);
        });
    } else {
        player.api("seekTo", 10);
    }
    

提交回复
热议问题