Hello everyone!
I statrted testing with videos in my game.
I am trying to play a video from a live stream.
The link of the stream is:
https://www.radiantmediaplayer.com/media/big-buck-bunny-360p.mp4
It is an example used by many people to test streaming. If you put it in browser it will automatically play the video.
Also when running my game i can see in the browser under network that the video was successfully loaded. (seen in the photo below).
In the code below i check if the video game object has some videoTexture to be played. But it is allways null.
Can u help me out / point me in the right direction?
import { GameObjects, Scene } from ‘phaser’
import { Constants } from ‘…/Common/Constants’;
import { Assets } from ‘./Assets’;
export class VideoFeed2 extends GameObjects.Container{
constructor(scene:Scene){
super(scene);this.videBckg = new GameObjects.Image(scene, 300, 300, Constants.SPRITESHEET, Assets.Board.Buttons.Neighbour_Bet.Normal); this.videBckg.setPosition(300,300); //this.add(this.videBckg); this.video = new GameObjects.Video(scene, 0, 0); this.video.loadURL(this.url, "canplay"); this.video.width = 300; this.video.height = 300; this.video.setPosition(300, 300); this.add(this.video); this.setVisible(true); } Play():void { if(this.video.videoTexture != null){ console.log("playing!!"); this.video.play(); }else{ console.log("texture is null!"); } } Stop():void { this.video.stop(); } Hide():void { console.log("video hidden") //this.visible = false; } Show():void { console.log("vide shown") //this.visible = true; } Toggle():void { this.visible ? this.Hide() : this.Show() } UpdatePositions(width:number, scale:number, leftPos:number, widthEnabled:boolean):void { //todo. } private video:GameObjects.Video; private url:string = 'https://www.radiantmediaplayer.com/media/big-buck-bunny-360p.mp4'; private videBckg:GameObjects.Image;
}