Home getDuration using Vimeo API
Reply: 0

getDuration using Vimeo API

mmdwc
1#
mmdwc Published in 2017-11-14 18:16:16Z

I'm trying to store in a variable the duration of a vimeo video using the API.

here is my code :

var iframe = document.querySelector('iframe');
var player = new Vimeo.Player(iframe);

var duree = player.getDuration().then(function(duration) {
    // duration = the duration of the video in seconds
}).catch(function(error) {
    // an error occurred
});

console.log(duree);

when I console.log my variable "duree", here is what I get :

Promise { <state>: "pending" }

the only way to get the duration in my console is to add console.log(duration); inside my function.

like this :

var duree = player.getDuration().then(function(duration) {
    console.log(duration);
}).catch(function(error) {
    // an error occurred
});

console.log(duree);

I don't understand what I am doing wrong, I only want to store the duration inside my variable "duree".

can anybody help me with this ?

thanks

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301532 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO