uyerdna Posted August 10, 2015 Share Posted August 10, 2015 Hi all I'm finishing up a little game and just now I found out that Safari is not so friendly with audio.I have tested my game working fine on the following browsers: chrome, firefox, IE, chrome android, and chrome ipad.I tested my game on Ipad 2's safari, but it says "error loading asset from URL null (no supported audio URL specified)"TypeError: 'null' is not an object (evaluating 'this.context.createGain')TypeError: 'undefined' is not an object (evaluating 'this.masterGain.gain') Tested on my PC's safari, the erorr is the same. My audio spec is- mp3 96kbps 22,050 kHz- fallback to ogg 96kbps 22,050 kHz Can anyone please give me some clue how to fix this? Thanks! Link to comment Share on other sites More sharing options...
qdrj Posted August 11, 2015 Share Posted August 11, 2015 I recommend to use m4a audio files for iOS devices. And ogg for Android. This combo cover all mobile and desktop devices. tips4design 1 Link to comment Share on other sites More sharing options...
uyerdna Posted August 13, 2015 Author Share Posted August 13, 2015 I just tested m4a files. No luck either. I keep getting the same error loading asset from URL null Here's a portion of my preload codepreload: function () { // load assets for the loading screen this.preloaderBar = this.add.sprite(this.game.world.centerX - 150,this.game.world.centerY, 'preloaderBar'); this.load.onLoadComplete.addOnce(this.onLoadComplete, this); this.load.setPreloadSprite(this.preloaderBar); // Begin load here this.game.load.bitmapFont('littera', 'assets/fonts/littera.png', 'assets/fonts/littera.xml'); this.load.image('mainmenu_bg', 'assets/mainmenu/mainmenu_bg.jpg'); this.load.atlas('mainmenu_atlas', 'assets/mainmenu/mainmenu_atlas.png', 'assets/mainmenu/mainmenu_atlas.json'); // AUDIO this.game.load.audio('bgm_menu', ['assets/audio/bgm_mainmenu.m4a', 'assets/audio/bgm_mainmenu.ogg']);}The game works perfectly fine on desktop and a couple of android devices (just managed to grab and test on some). I'm beginning to think that it's an issue from iOS itself: https://paulbakaus.com/tutorials/html5/web-audio-on-ios/But this is 2015 and I think Phaser is using web audio. In worst case, audio on iOS should be loaded perfectly and muted by default until user interaction. Is there anything else that I can try? Link to comment Share on other sites More sharing options...
uyerdna Posted August 16, 2015 Author Share Posted August 16, 2015 bumping this Link to comment Share on other sites More sharing options...
georgejfrick Posted August 16, 2015 Share Posted August 16, 2015 Can you post more of the code or more of a stack trace (both?). We're doing m4a with fallback to ogg and we're working fine on Safari on iOS and we're working fine on iPad. All of our sound problems are in older versions of IE when the sound is mono. Link to comment Share on other sites More sharing options...
uyerdna Posted August 19, 2015 Author Share Posted August 19, 2015 Hi My code is pretty standard; it works well on Chrome and Firefox, even on Android's stock browser Here's the log from Safariaudio[bgm_menu]: error loading asset from URL null (no supported audio URL specified)audio[bgm_game]: error loading asset from URL null (no supported audio URL specified) Followed byTypeError: 'null' is not an object (evaluating 'this.context.createGain')TypeError: 'undefined' is not an object (evaluating 'this.masterGain.gain') Fthese above I think is because the game tried to play a sound that is not properly loadedActually looking at the console log, all sound files are not loaded on Safari What is your audio file's quality (kbps, khz)? That might be the issue here? Link to comment Share on other sites More sharing options...
uyerdna Posted August 21, 2015 Author Share Posted August 21, 2015 I figured there is something wrong with my audio files so I tried- converting them to 128kbps 44100hz, no luck- try importing a mp3 sound that comes with the phaser sample, not working either- updating from phaser 2.3.0 to the latest 2.4.2, nope The game is working perfectly fine on mobile / desktop, only on browsers other than safariIt seems like safari is handling this audio loading stuff differently than other browsers. At least to me, that seems to be the case. I'm using firebug lite to show console on my ipad http://iosbookmarklets.com/tutorials/firebug-lite-bookmarklet/And from there I see that the requests to load audio files fail. Loading json, xml worked great Problem could be this, but I'm not sure if it is and how to fix this http://stackoverflow.com/questions/1995589/html5-audio-safari-live-broadcast-vs-not This would be the perfect time for Richard to show up and show me some light. Kinda desperate here now Link to comment Share on other sites More sharing options...
Mikko Posted October 2, 2015 Share Posted October 2, 2015 I had this problem too. No format worked on Ipad Safari. Then looked through phaser examples and only one of them worked. The solution is to have the first sound play on a button click. No other inputdown etc works. var button = game.add.button(x, y, 'button', click, this, 0, 1, 2); Click function would play the first sound. After this other sounds work as expected. Make this your start game button etc. This is an apple security etc stupid feature that requires human interaction to start playing sounds. m4a worked as format. georgejfrick 1 Link to comment Share on other sites More sharing options...
Recommended Posts