0

I have this jquery to get the current time of my embed code from vimeo.

var _getPlayerVimeo = function () {
            var VIMEO_PLAYER1 = new Vimeo.Player($('iframe#player1'));
            var _currentTime = VIMEO_PLAYER1.getCurrentTime().then(function (seconds) {
                return seconds;
            });
            console.log(_currentTime);

        };

        $('.close-vimeo').on("click", _getPlayerVimeo);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://player.vimeo.com/api/player.js"></script>
<button class="close-vimeo">button</button>
                <div class="playerDiv">
                    <iframe id="player1" src="https://player.vimeo.com/video/181101656?portrait=0" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
                    <iframe id="player2" src="https://player.vimeo.com/video/180966954?portrait=0" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
                </div>

The Class .close-vimeo is a button to close the player. And this is the return from the console after the button close has been triggered:

Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}

EDIT: Anyway my goal for this question is that I want to get the currentTime of the player once the user clicked a "close" button (since the player is in modal).

jek
  • 148
  • 1
  • 1
  • 12
  • `then` always returns a `Promise`, never the callback value. The Promise API is all about chaining together functions that will execute at some point in the future when some kind of asynchronous task is complete. You need to put the `console.log` statement inside the `.then` callback. – 4castle Aug 25 '17 at 06:22
  • note ... `.then(function (seconds) { return seconds; });` is essentially a NOP :p – Jaromanda X Aug 25 '17 at 06:25
  • So what do you guys can suggest to me in order for this to work? – jek Aug 25 '17 at 07:22

0 Answers0