Jump to content

playing videos on mobile


niceWeather
 Share

Recommended Posts

I did a project where a video is played automatically upon entering the instruction screen. The whole game runs in an iFrame and the code I use is the following:

Sheeple.State.Instructions1.prototype.preload = function() {
	this.load.video('Video1', 'video/video.mp4'); // it's 6 seconds "long"
};

Sheeple.State.Instructions1.prototype.create = function() {
	// add video to game
	this.video = this.game.add.video('Video1');
	this.video.crossorigin = 'anonymous';

	// add video to world to make it viewable
	this.videoAdd = this.video.addToWorld(this.game.width / 2.13, this.tv.position.y - 456, 0.5, 0.5);
	// set anchor and size of video (world)
	this.videoAdd.anchor.set(0.5);
	this.videoAdd.scale.set(1.3);

	// add function to be executed on completion of movie clip 
	this.video.onComplete.add(this.introClip, this);
	// wait half a second until you play the movie clip 
	this.game.time.events.add(500, function() {
		this.video.play();
	}, this);
};

All works well as long as its played on a desktop computer, but for mobile it does not always work.

I understand that some mobile devices require the user to tap the video to start playing and I'm not asking for that. The problem lies therein that on some devices the images are not displayed although the sound is being played. (e.g. Chrome and standard browser for Galaxy S6)

Link to comment
Share on other sites

  • 6 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...