rich Posted July 16, 2013 Share Posted July 16, 2013 I've spent a long time working on this but I'm happy to say that Phaser 1.0 features a complete audio overhaul. It was literally rebuilt from the ground-up. I like bullet-point feature lists, so here is one Full Web Audio and legacy Audio Tag supportGlobal and Sound specific mute and volume controlsIntelligently handles the iOS playback locking issue, where you can't load/play audio until a touch event has been receivedLoop both web audio and audio tagPlayback from any positionMulti-format loader. Just give the loader an array of sound files and it'll load the first one your device supportsLoader linked to iOS playback lock, so if the device is in a locked state it will defer loading until unlockedHandles file decoding without bunching up. mp3s for example can often take a while to decode, playback happens on completionEasily create audio sprites by defining markers within a single sample and giving them unique namesAudio sprites work across web audio and legacy audio, so you can batch your sounds together into one mp3 even when using web audioSound events: load, play, loop, stop, restartEasy access to a sounds gainNode and context so you can implement your own effectsEasily disable Web Audio / legacy Audio support, regardless of what the browser can handleEasily disable the whole sound system so you can link in your own 3rd party audio library if you wish Getting very excited about starting to prepare the 1.0 release austin, Mike, deis and 1 other 4 Link to comment Share on other sites More sharing options...
deis Posted July 16, 2013 Share Posted July 16, 2013 This sounds amazing! (Pun intended) I am really looking forward to 1.0 release as I have a big project in the pipeline that will utilize it. Link to comment Share on other sites More sharing options...
Mike Posted July 16, 2013 Share Posted July 16, 2013 Your excitement is shared! Link to comment Share on other sites More sharing options...
xerver Posted July 17, 2013 Share Posted July 17, 2013 Having just done the same in grapefruit I understand the amount of work this took, very cool. For the playback lock, do you just listen for a touch event, then fire queued loads? Link to comment Share on other sites More sharing options...
rich Posted July 17, 2013 Author Share Posted July 17, 2013 For the iOS lock if they are on iOS5, and thus legacy Audio only, then I defer the load of the Audio tag data until the games first touch event, yes. If they are on iOS6 then I wait for the first touch event and then dynamically create a tiny little bit of audio that is silence and play it - because if you don't as you know the audio system remains locked! I do this because it's not guaranteed that any sounds will have loaded or are queued to be played when the first touch event is received. Link to comment Share on other sites More sharing options...
alex_h Posted July 18, 2013 Share Posted July 18, 2013 This sounds great! Is it being built in such a way that it could be used independently from the rest of Phaser? Say if I had a game I wanted / needed to build with a different framework for whatever reason, could I grab the Phaser Audio module and use it for the sound in that game? Link to comment Share on other sites More sharing options...
Bizzi Posted July 19, 2013 Share Posted July 19, 2013 Use you only the Audio API for that?Exmaple: <audio> HTML Tag or over Javascript "var sound = new Audio();",.. Better solution is to use the AudioContext, but you dont have Problems on Mobile devices.For example, Apple forbids "easy for use autoplay sounds" by using the Audio-Tag or the new Audio() API. Best solution: http://www.html5rocks.com/en/tutorials/webaudio/intro/ Link to comment Share on other sites More sharing options...
rich Posted July 19, 2013 Author Share Posted July 19, 2013 Phaser uses both the audio tag AND the Web Audio API. Web Audio isn't very well supported on mobile yet, so any decent game framework has to support both methods imho. Apple forbids auto playing ANY sound, no matter if it's audio tag or web audio. Link to comment Share on other sites More sharing options...
Bizzi Posted July 23, 2013 Share Posted July 23, 2013 Web Audio isn't very well supported on mobile yet, so any decent game framework has to support both methods imho. Apple forbids auto playing ANY sound, no matter if it's audio tag or web audio.Sure, but i says that you use the AudioContext-API not the Audio-API. I have seen that on an other html5 game - And HERE sounds will be automatical played on iOS!I search the game on my browser-chronic and give you an link tomorrow. Link to comment Share on other sites More sharing options...
Bizzi Posted July 24, 2013 Share Posted July 24, 2013 Ok, i have found that, check it out: http://labs.dinahmoe.com/plink/ testet in iOS 6 with Safari Link to comment Share on other sites More sharing options...
rich Posted July 24, 2013 Author Share Posted July 24, 2013 AudioContext is the Web Audio API! When I talk about Web Audio it's exactly the same thing. Phaser supports using the Audio tag and AudioContext (Web Audio). You cannot play sounds automatically in iOS, even using AudioContext. The only reason that demo link you provided above works is that you have to press the "Play" button to get it started. If you don't start playback directly from a user initiated touch event then all AudioContext playback enters a SCHEDULED state in the context buffer. I suspect you misread my post where I said "Apple forbids auto playing ...", i.e. playing sounds without any user intervention. I didn't mean they don't allow audio! iOS6 is the best for audio playback right now, but you still have to kick it off from a touch event. Link to comment Share on other sites More sharing options...
Bizzi Posted July 24, 2013 Share Posted July 24, 2013 Okay, than i have understand you, Sorry.Yet i have read it on the API Documentation. In iOS 6 the user muss interact the first time to play the Audio.But here we can create a Splashscreen and the user must click/tap on a button or what else.Otherwise an a Gamemenu exists Sound settings - These are on iOS disabled first time. If the user set that "on", the interaction start the sounds on the background. Link to comment Share on other sites More sharing options...
rich Posted July 24, 2013 Author Share Posted July 24, 2013 Yes the most common way to get around it is to have a "Music On" button on the game menu. Because as soon as the user touches it you have the permissions you need to start the audio downloading (for Audio) or playing (for AudioContext). An alternative is to just have silence on the menu and not start any audio at all until they press Play to enter the game. Link to comment Share on other sites More sharing options...
qzix13 Posted January 2, 2014 Share Posted January 2, 2014 rich, can you write step by step instruction how to load and play sounds on iOS? because I try to run sounds on iOS and it doesnt work. (I use Phaser). Link to comment Share on other sites More sharing options...
Recommended Posts