vimeo / player.js

Interact with and control an embedded Vimeo Player.

Home Page:https://player.vimeo.com/api/demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with requestPictureInPicture

mu-costa opened this issue · comments

Expected Behavior

When I instanced a player object I tried to initialize the player at PiP's mode but the requestPictureInPicture doesn't seem to work.

Actual Behavior

The requestPictureInPicture doesn't work

Steps to Reproduce

<script src="https://player.vimeo.com/api/player.js"></script> <script> const options = { id: 944548886, width: 480, height: 720 }
    const player = new Vimeo.Player('myPlayer', options);

    player.setVolume(0);

    player.ready().then(function () {
        // the player is ready
        console.log('player is ready')
    });

    player.getPictureInPicture().then(function (pip) {
        console.log(pip)
    });

    player.on('play', function () {
        console.log('played the video!');
    });
    player.play()
    player.requestPictureInPicture()

</script>

Browsers generally require a user interaction with the iframe before the request will be allowed. I think you should see an error if you add a .catch() to the request promise.

But ultimately I would not rely on doing all of this programmatically unless it is from a user interaction. And make sure you are handling errors from all API calls in case they don't work.

Thank you @bdougherty ! I realized that after trying to do this implementation but I'm gonna try another approach because the task that was assign to me I've to trigger the PiP video automatically after the click in a button.