How to play multiple html5 audio files in iOS?











up vote
2
down vote

favorite
1












Let's say I have two audio files. I hooked them up with my javascript.



var audio1 = new Audio();
audio1.src = 'file1';
audio1.load();

var audio2 = new Audio();
audio2.src = 'file2';
audio2.load();


when I play audio1 then play audio2, mobile safari (ios) stops audio1 then plays audio2. It only happens with ios safari.










share|improve this question


























    up vote
    2
    down vote

    favorite
    1












    Let's say I have two audio files. I hooked them up with my javascript.



    var audio1 = new Audio();
    audio1.src = 'file1';
    audio1.load();

    var audio2 = new Audio();
    audio2.src = 'file2';
    audio2.load();


    when I play audio1 then play audio2, mobile safari (ios) stops audio1 then plays audio2. It only happens with ios safari.










    share|improve this question
























      up vote
      2
      down vote

      favorite
      1









      up vote
      2
      down vote

      favorite
      1






      1





      Let's say I have two audio files. I hooked them up with my javascript.



      var audio1 = new Audio();
      audio1.src = 'file1';
      audio1.load();

      var audio2 = new Audio();
      audio2.src = 'file2';
      audio2.load();


      when I play audio1 then play audio2, mobile safari (ios) stops audio1 then plays audio2. It only happens with ios safari.










      share|improve this question













      Let's say I have two audio files. I hooked them up with my javascript.



      var audio1 = new Audio();
      audio1.src = 'file1';
      audio1.load();

      var audio2 = new Audio();
      audio2.src = 'file2';
      audio2.load();


      when I play audio1 then play audio2, mobile safari (ios) stops audio1 then plays audio2. It only happens with ios safari.







      ios html5 audio






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 9 '12 at 7:12









      Moon

      9,43658158251




      9,43658158251
























          3 Answers
          3






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          As far as I'm aware, this is a design decision from Apple, it'S not possible to play more than one audio file.






          share|improve this answer





















          • @lan Devlin // yes..that what I found out too..
            – Moon
            Jan 9 '12 at 21:39












          • crazy , i just use this : stackoverflow.com/questions/5194898/html5-audio-multiple-play/… I can play as much as I want audio files. I just check now , background music works with click sounds on iOS mini ipad.
            – Nikola Lukic
            Feb 17 '16 at 14:24




















          up vote
          1
          down vote













          I did some testing on this recently. The short answer is as stated before, it doesn't work. I tried working with mp3,m4a(aac I purchased on itunes),mp4 and aif, so file format has no bearing on iOS safari's ability to play more than one stream at a time.



          I have currently "solved" the issue in my web app by assigning priorities to sounds in the app so it can intelligently interrupt or ignore requests to play a sound file. Maybe you can try something similar.






          share|improve this answer




























            up vote
            0
            down vote













            One possible workaround is to use server-side utility like sox to mix multiple audio files into one. It is not equivalent to playing multiple audio files at random position but depending on your needs it can be a solution.






            share|improve this answer





















              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8785022%2fhow-to-play-multiple-html5-audio-files-in-ios%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              3
              down vote



              accepted










              As far as I'm aware, this is a design decision from Apple, it'S not possible to play more than one audio file.






              share|improve this answer





















              • @lan Devlin // yes..that what I found out too..
                – Moon
                Jan 9 '12 at 21:39












              • crazy , i just use this : stackoverflow.com/questions/5194898/html5-audio-multiple-play/… I can play as much as I want audio files. I just check now , background music works with click sounds on iOS mini ipad.
                – Nikola Lukic
                Feb 17 '16 at 14:24

















              up vote
              3
              down vote



              accepted










              As far as I'm aware, this is a design decision from Apple, it'S not possible to play more than one audio file.






              share|improve this answer





















              • @lan Devlin // yes..that what I found out too..
                – Moon
                Jan 9 '12 at 21:39












              • crazy , i just use this : stackoverflow.com/questions/5194898/html5-audio-multiple-play/… I can play as much as I want audio files. I just check now , background music works with click sounds on iOS mini ipad.
                – Nikola Lukic
                Feb 17 '16 at 14:24















              up vote
              3
              down vote



              accepted







              up vote
              3
              down vote



              accepted






              As far as I'm aware, this is a design decision from Apple, it'S not possible to play more than one audio file.






              share|improve this answer












              As far as I'm aware, this is a design decision from Apple, it'S not possible to play more than one audio file.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jan 9 '12 at 9:01









              Ian Devlin

              15.8k44864




              15.8k44864












              • @lan Devlin // yes..that what I found out too..
                – Moon
                Jan 9 '12 at 21:39












              • crazy , i just use this : stackoverflow.com/questions/5194898/html5-audio-multiple-play/… I can play as much as I want audio files. I just check now , background music works with click sounds on iOS mini ipad.
                – Nikola Lukic
                Feb 17 '16 at 14:24




















              • @lan Devlin // yes..that what I found out too..
                – Moon
                Jan 9 '12 at 21:39












              • crazy , i just use this : stackoverflow.com/questions/5194898/html5-audio-multiple-play/… I can play as much as I want audio files. I just check now , background music works with click sounds on iOS mini ipad.
                – Nikola Lukic
                Feb 17 '16 at 14:24


















              @lan Devlin // yes..that what I found out too..
              – Moon
              Jan 9 '12 at 21:39






              @lan Devlin // yes..that what I found out too..
              – Moon
              Jan 9 '12 at 21:39














              crazy , i just use this : stackoverflow.com/questions/5194898/html5-audio-multiple-play/… I can play as much as I want audio files. I just check now , background music works with click sounds on iOS mini ipad.
              – Nikola Lukic
              Feb 17 '16 at 14:24






              crazy , i just use this : stackoverflow.com/questions/5194898/html5-audio-multiple-play/… I can play as much as I want audio files. I just check now , background music works with click sounds on iOS mini ipad.
              – Nikola Lukic
              Feb 17 '16 at 14:24














              up vote
              1
              down vote













              I did some testing on this recently. The short answer is as stated before, it doesn't work. I tried working with mp3,m4a(aac I purchased on itunes),mp4 and aif, so file format has no bearing on iOS safari's ability to play more than one stream at a time.



              I have currently "solved" the issue in my web app by assigning priorities to sounds in the app so it can intelligently interrupt or ignore requests to play a sound file. Maybe you can try something similar.






              share|improve this answer

























                up vote
                1
                down vote













                I did some testing on this recently. The short answer is as stated before, it doesn't work. I tried working with mp3,m4a(aac I purchased on itunes),mp4 and aif, so file format has no bearing on iOS safari's ability to play more than one stream at a time.



                I have currently "solved" the issue in my web app by assigning priorities to sounds in the app so it can intelligently interrupt or ignore requests to play a sound file. Maybe you can try something similar.






                share|improve this answer























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  I did some testing on this recently. The short answer is as stated before, it doesn't work. I tried working with mp3,m4a(aac I purchased on itunes),mp4 and aif, so file format has no bearing on iOS safari's ability to play more than one stream at a time.



                  I have currently "solved" the issue in my web app by assigning priorities to sounds in the app so it can intelligently interrupt or ignore requests to play a sound file. Maybe you can try something similar.






                  share|improve this answer












                  I did some testing on this recently. The short answer is as stated before, it doesn't work. I tried working with mp3,m4a(aac I purchased on itunes),mp4 and aif, so file format has no bearing on iOS safari's ability to play more than one stream at a time.



                  I have currently "solved" the issue in my web app by assigning priorities to sounds in the app so it can intelligently interrupt or ignore requests to play a sound file. Maybe you can try something similar.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 26 '12 at 18:26









                  Rob Lynch

                  44628




                  44628






















                      up vote
                      0
                      down vote













                      One possible workaround is to use server-side utility like sox to mix multiple audio files into one. It is not equivalent to playing multiple audio files at random position but depending on your needs it can be a solution.






                      share|improve this answer

























                        up vote
                        0
                        down vote













                        One possible workaround is to use server-side utility like sox to mix multiple audio files into one. It is not equivalent to playing multiple audio files at random position but depending on your needs it can be a solution.






                        share|improve this answer























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          One possible workaround is to use server-side utility like sox to mix multiple audio files into one. It is not equivalent to playing multiple audio files at random position but depending on your needs it can be a solution.






                          share|improve this answer












                          One possible workaround is to use server-side utility like sox to mix multiple audio files into one. It is not equivalent to playing multiple audio files at random position but depending on your needs it can be a solution.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jun 7 '12 at 1:43









                          David Mongeau-Petitpas

                          936




                          936






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8785022%2fhow-to-play-multiple-html5-audio-files-in-ios%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              404 Error Contact Form 7 ajax form submitting

                              How to know if a Active Directory user can login interactively

                              Refactoring coordinates for Minecraft Pi buildings written in Python