Soundjs on iphone

103 views
Skip to first unread message

PJR

unread,
May 1, 2016, 6:37:46 AM5/1/16
to CreateJS Discussion

I have just joined this group since I have very recently started using soundjs. It works fine on a Windows platform and looks like a good solution for inserting audio into html/js games.

I am trying to get it to work on mobile - iphone, ipad etc.

I can see that there has been considerable discussion on this topic but I am still unable to determine the exact sequence of commands that will allow this. There is some discussion of using plugins and some that say you just need to play a blank mp3 before the real mp3. However these do not seem to work for me!

Is there any simple demo code out there that shows the exact sequence of javascript/soundjs lines of code that are needed?

I would be very appreciative of any help!

Lanny

unread,
May 17, 2016, 4:14:37 PM5/17/16
to CreateJS Discussion
If you are just playing in Mobile Safari, there is no longer anything you need to do -- SoundJS will automatically listen for a document click, and play an empty sound for you.

What version of SoundJS are you using, and what version of iOS?

PJR

unread,
May 18, 2016, 9:02:19 AM5/18/16
to CreateJS Discussion


Thanks for your response.

The code has

<script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>

is this the latest version?

It just uses createjs.Sound.registerSound to load sounds then createjs.Sound.play to play sounds with an empty sound played before:

      function playSound (isound) {     
            createjs.WebAudioPlugin.playEmptySound();
            createjs.Sound.play(soundID[isound-1]);   
      };

The sound is triggered from a button click. This works fine on Win 10

 <body  onLoad="loadSounds();">
        <button onClick="playSound(1)" class="myButton">DO</button>   
    </body>

Lanny

unread,
May 19, 2016, 11:07:09 AM5/19/16
to CreateJS Discussion
If you are playing the sound on a button click, the empty sound is unnecessary. The whole reason the empty sound workaround exists is so you can play audio without user interaction. WebAudio requires audio to be played on a user event (keyboard, mouse, etc) in order to "unlock" the audio context. If you are playing a sound on button click, you are satisfying that requirement already.

Something else must be going on. What version of iOS are you using?

PJR

unread,
May 21, 2016, 8:55:38 AM5/21/16
to CreateJS Discussion
Am using IOS 9.3.2 on iphone 6S

Here is minimlist code that works fine on PC running Win 10. Simply loads and plays one MP3 file.

<html>
<head>

    <script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>   
</head>
 <script>   
var soundID = "Shot";     
function load_Sound(){
    createjs.Sound.registerSound("http://users.tpg.com.au/metonics/Sounds/gunshot.mp3", soundID);       
    };
       
function play_Sound(){
    createjs.Sound.play(soundID);
    };
   
</script>  
 <body  onLoad="load_Sound();">
    <button onClick="play_Sound()">Shot </button>
</body> 
</html>

PJR

unread,
May 11, 2017, 10:27:22 PM5/11/17
to CreateJS Discussion

I never really got an answer for this

I use dropbox so files can be run from PC, ipad, iphone etc,

On the PC I get sound; on the IOS machines silence only! Is there any reason for this?

Any help much appreciated! Minimalist code attached below

<html>
<meta charset="utf-8">


<head>
    <script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>   
</head>

 <script>
   
var soundID = "Shot";
     
function load_Sound(){
    createjs.Sound.registerSound("http://users.tpg.com.au/metonics/Sounds/gunshot.mp3", soundID);       
    };
       
function play_Sound(){
    createjs.WebAudioPlugin.playEmptySound();
Reply all
Reply to author
Forward
0 new messages