Play video in the background

I borrowed this code from Phaser lab for playing video.

var video = document.createElement('video');
video.playsinline = true;
video.src = './assets/ocean.mp4';
video.width = 800;
video.height = 450;
video.autoplay = true;
var element = this.add.dom(400, 300, video);

However, it keeps returning “this.add.dom” is not a function.
(I added dom:{createContainer: true} to my config, didn’t fix the problem)

Any suggestions?

Which Phaser version are you using? Maybe it’s an old one.

You can use a video game object directly.

1 Like