React360 - Video events cannot be added

Asked

Viewed 17 times

0

I’m trying to understand the moment a video was completed. I tried to use video events as the documentation says, but I can’t add an event listener to my video player; when I do, I get the "addeventlistener is not fuction" error. I hope someone knows what’s going on. This is my code:

VideoModule.createPlayer('myplayer');

VideoModule.play('myplayer', {
	source: { url: videoPath }, 
	stereo: '3DTB', 
	volume: 1,
	muted: false,
});

Environment.setBackgroundVideo('myplayer');

// the evet should be here
VideoModule.addEventListener('onVideoStatusChanged', (event: VideoStatusEvent) => {
    if (event.status === 'finished') {
        console.log('Video is finished');
    }
})

}

1 answer

1


This was also a problem for me, so I fixed addListener documentation in receiving request #758

https://github.com/facebook/react-360/pull/758

Good to solve your problems just change the function "addeventlistener" to "addListener", see a correct example:

player.addListener('onVideoStatusChanged', (event) => {
  if (event.status === 'finished') {
    console.log('Video is finished');
  }
})

Browser other questions tagged

You are not signed in. Login or sign up in order to post.