Sam Posted August 13, 2014 Share Posted August 13, 2014 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 More sharing options...
lewster32 Posted August 13, 2014 Share Posted August 13, 2014 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. Sam 1 Link to comment Share on other sites More sharing options...
Sam Posted August 13, 2014 Author Share Posted August 13, 2014 wow, very fast answer!So I have to work around, no problem at all. But good to know on which side the problem depends.Thanks lewster32 1 Link to comment Share on other sites More sharing options...
rich Posted August 13, 2014 Share Posted August 13, 2014 Yup there's no work-around, it's a browser based restriction I'm afraid. Link to comment Share on other sites More sharing options...
Sam Posted August 13, 2014 Author Share Posted August 13, 2014 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 More sharing options...
rich Posted August 13, 2014 Share Posted August 13, 2014 No it happens on some Android browsers too, but it's a restriction they are slowly removing. In a year or so it will be a thing of the past. haden and Sam 2 Link to comment Share on other sites More sharing options...
Sam Posted November 20, 2014 Author Share Posted November 20, 2014 Update to this post: NOV 2014CocoonJS 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 More sharing options...
Sam Posted November 20, 2014 Author Share Posted November 20, 2014 Update to this post: NOV 2014CocoonJS 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 More sharing options...
Recommended Posts