Unmute vimeo after video play event using api

38 Views Asked by At

I create vimeo player AFTER I click in the page (so user interaction has happened): I would like to unmute Vimeo video after video has started. This method works with Youtube.

 videoIframe = $(<iframe width="100%" height="100%" src="//player.vimeo.com/video/367973275?byline=1&portrait=1&title=1&autopause=1&loop=1&playsinline=1&dnt=1&background='+controls+'&autoplay=1';" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>)

vimeoPlayer = new Vimeo.Player(videoIframe);
vimeoPlayer.on('play', onVimPlay);

function onVimPlay(){
    vimeoPlayer.setVolume(1).then(function(volume) {
            // volume was set
        }).catch(function(error) {
            switch (error.name) {
                case 'RangeError':
                    // the volume was less than 0 or greater than 1
                    break;

                default:
                    // some other error occurred
                    break;
            }
            console.log(error)
    

however vimeo still refuses to set volume with a message:

Unmuting failed and the element was paused instead because the user didn't interact with the document before

0

There are 0 best solutions below