Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
531 views
in Technique[技术] by (71.8m points)

html - Fire event when vimeo video stops playing?

I was just wondering if it was possible to fire an event once a vimeo video has finished playing?

Currently I have a Vimeo embed in an overlay, that I want to remove once the video has stopped. Hope this makes sense!

I dont really have any code that would be of use, but would like to know if you can add event listeners to the video, fire an event once the video has finished, and how you would go about doing this?

Thanks Ryan

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Previous answer is now obsolete since Vimeo launching the new Video Player API.

Important: Be sure to remove the ?api=1 from the URL in your iframe. This was previously required when using the Froogaloop library and is no longer needed. If you leave it in, the 'ended', 'seeked' and other events will never fire.

Include the new script:

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

And then use the following example:

$(document).ready(function(){

    var iframe = $('#container iframe');
    var player = new Vimeo.Player(iframe);

    player.on('ended', function() {
        console.log('Finished.');
    });

});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...