Jump to content

Phaser: music only plays on first touch (focus)


Sam
 Share

Recommended Posts

Hello everyone,

I am developing with Phaser for a few weeks and got stuck with an issue that themes to be Phaser sited.
You can see the code below-> The soundfile is only playing if the loaded game is touched. (Themes to be a focus-problem?)
There is no function etc. around the code below. The soundfiles are very small and encoded very fast.

I'm using latest Phaser (2.0.7) and cocoonjs (2.0.2).
This issue themes to be affect every iOS Device. Maybe someone can help.

cheers,


Code:
preload:

this.load.audio('menu', ['assets/audio/menu.mp3', 'assets/audio/menu.ogg']);

create:

this.menuMusic = game.add.audio('menu');this.menuMusic.play('',0,1,true);

Testing Devices:
iPad mini (iOS 7)
iPad Air (iOs 7)
iPhone 4s (iOs 7)
iPhone 4 (iOs 7)
iPhone 5 (iOs 7)

Sound-file-info:
.mp3  file:
length: 00:12 (seconds)
296 KB

.ogg file:
lenght: 00:12 (seconds)
666KB

Link to comment
Share on other sites

This is a restriction with iOS browsers - you must trigger sound via a touch interaction. This is usually solved by having the user press a button to start the game, or tap an intro screen to start the main menu etc. Unfortunately I don't think there's a workaround; this is an Apple restriction.

Link to comment
Share on other sites

A "press-button" or "touch to start" screen  isn't worse at all. In fact it can be a lil' bit nostalgia.
Good to know that this isn't a Phaser-based problem. The framework performs well and gives us great opportunities.

Can you confirm that this only affects iOS?

thank for the super-fast support ;)

Link to comment
Share on other sites

  • 3 months later...

Update to this post: NOV 2014
CocoonJS and Cordova seems to handle sound very well now on appstart.
Nonetheless you should use a boot function to be sure everything is loaded - cocoonJS and apache cordova will play sound without having to do a first touch or something.

Link to comment
Share on other sites

Update to this post: NOV 2014
CocoonJS and Cordova seems to handle sound very well now on appstart.
Nonetheless you should use a boot function to be sure everything is loaded - cocoonJS and apache cordova will play sound without having to do a first touch or something.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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