7 Replies Latest reply on Jun 10, 2014 5:21 PM by ChipNow

    Associating music with symbols (was: Music)

    soulforged

      I made a symbol as a scene of my animation and I need to insert my music into my symbol but when i do it, it plays even if i am on main stage and symbol is hidden. How to make something like playing the music after the symbol appears?

        • 1. Re: Associating music with symbols (was: Music)
          jbowden Adobe Employee

          Hi there,

           

          The only way audio could play in a symbol is if the audio element is set to "Autoplay". Uncheck that, and then you can control when the audio actually plays.There are a couple of ways you could control audio playback:

          1. Add a stop trigger to the symbol timeline, and then add a play action to the audio element after the stop trigger. You'd of course have to tell the symbol to play, too (but I expect you're already doing that)
          2. Add some JavaScript to your symbol play command to also play the audio at the same time, e.g. sym.$("my_audio_element")[0].play();

           

          hth,

          Joe

          1 person found this helpful
          • 2. Re: Associating music with symbols (was: Music)
            ChipNow Level 1

            As a follow on question, I have two symbols, each with audio. The symbols do not overlap on the main timeline. Desktop browsers work as expected: audio plays in the order of the the symbols are played on the timeline. Mobile doesn't work. Whichever symbol appears first in the timeline gets its audio played. The second symbol's audio does not play. How can I get a symbol to assign itself to whatever audio channel the mobile browser has configured for the first symbol? From the "Mobile Considerations" section on this page (bottom), it sounds like this reassignment would happen automatically. Am I configuring something incorrectly?

             

            Should I create another item for this question?

            • 3. Re: Associating music with symbols (was: Music)
              ChipNow Level 1

              I created a soundtrack (which plays on mobile) on the stage and tried this within the symbol but it didn't work (on mobile - it too works fine on the desktop)...

               

              Screen Shot 2014-06-08 at 1.53.23 AM.png

              • 4. Re: Associating music with symbols (was: Music)
                jbowden Adobe Employee

                Hi there,

                 

                I guess you're lucky that you got even one symbol to play back audio in this "autoplay" type of situation, as mobile devices generally require an explicit play command to the audio element from a user event such as click, touch, or swipe. Also, mind the syntax. In general, HTML5 audio elements expect this kind of syntax for a play command:

                 

                sym.$("your_audio_element")[0].play();

                 

                Naturally, replace your_audio_element with the name of your audio element. If you have code like this on a click or touch event, it should work on mobile, as long as the calling element and audio element are at the same symbol level. Otherwise, you'll want to getSymbol first, e.g.:

                 

                sym.getSymbol("your_symbol").$("your_audio_element")[0].play();

                 

                hth,

                Joe

                1 person found this helpful
                • 5. Re: Associating music with symbols (was: Music)
                  ChipNow Level 1

                  Thanks for your reply, Joe.

                   

                  Here is a demo of the issue: Test01 - Mobile Audio. It plays in desktop browsers, not in mobile. After the initial tap, both Android and iOS play the audio in the first symbol, not in the second.

                   

                  My project is divided into sections, each will be a symbol. It is ideal to keep the audio for that section in the symbol with its visual components. Is there anyway to get that to work? If not, any suggestions?

                   

                  Again, should I create a new question for this?

                  • 6. Re: Associating music with symbols (was: Music)
                    jbowden Adobe Employee

                    You should probably start a new question for this, ChipNow. I'll give you a high-level answer to your question here, but we can continue discussing the implications in your new question: iOS (and most mobile devices) require audio playback to be explicitly initiated by a user event, and won't normally work with Animate's autoplay timeline mechanisms.

                    1 person found this helpful
                    • 7. Re: Associating music with symbols (was: Music)
                      ChipNow Level 1

                      Yeah. I know about the mobile requirement for interaction. It's not clear what that means with multiple audio files inside symbols that need to be synchronized with their symbol's animation. I'll create another question. Again, thanks for your reply.