11 Replies Latest reply on Oct 6, 2006 6:34 AM by davefc

    Published Audio Not Playing

    davefc Level 1
      I have the following test code (below) as a button event handler. It works just fine in the Flash IDE, but does not work when I publish and then bring up the generated HTML file in IE 6. In both scenarios, the audio file bytes are streamed from the server and the onLoad() is called successfully, showing the correct byte count that matches what the server sends. However, I only hear the audio in IDE mode, not in publish mode. (Changing the loadSound() to stream the audio produces the same problem: the audio is heard in IDE mode; not heard in HTML/published mode). I have fiddled with all the Flash security and audio compression publish settings to no avail... My files are 11 KHz MP3 files.

      Thanks for your help!!

      function correctButtonclicked() {

      trace("Correct");
      var aSound:Sound = new Sound();
      aSound.onLoad = function(success:Boolean) {
      if(success) {
      mx.controls.Alert.show("Audio Loaded Successfully:" +
      aSound.getBytesLoaded() + ":" + aSound.getBytesTotal());
      aSound.start();
      }
      };
      aSound.loadSound(" http://maniac.ckint.com:19181/quizapp/AudioServlet?InteractionId=1&InteractionItemTypeId=2 ", false);
      }
        • 1. Re: Published Audio Not Playing
          abeall Level 3
          You say the onLoad fires successfully when in the HTML?

          Are you attempting to load the audio cross domain?
          • 2. Re: Published Audio Not Playing
            davefc Level 1
            Thanks for the response.

            I get the same results whether I run the HTML page from my PC or from the same domain as the sound file is coming from on the Java application/web server. So, I do not think there is a cross-domain issue.

            For both the Flash IDE and HTML scenarios, the bytes received and total bytes are correct, and the onLoad fires with a success parameter of 'true'. I just don't hear any audio in the HTML scenario...

            Any other ideas? Thanks for your help!

            Dave
            • 3. Re: Published Audio Not Playing
              davefc Level 1
              Additional information: When I replace the servlet call with a static sound file URL, the sound plays in both IDE and HTML scenarios (I am sending the exact same file in both scenarios below, and byte counts are identical at the server and the client):

              //FAILS: aSound.loadSound(" http://maniac.ckint.com:19181/quizapp/AudioServlet?InteractionId=1&InteractionItemTypeId=2 ", false);

              //WORKS: aSound.loadSound(" http://www.dave.com/zzzabc/q1.mp3", false);

              Does the Flash 8 Plugin not support streaming of sound files from a servlet with GET parameters? Does it require a static sound file URL? Why does the IDE behave differently?

              Thanks!
              • 4. Re: Published Audio Not Playing
                abeall Level 3
                > Does the Flash 8 Plugin not support streaming of sound files from a servlet with GET parameters?
                Possibly, I've never needed to do this, but as long as it's sending back an MP3 Flash shouldn't know the difference where it's coming from, I would think.

                If you are doing anything cross-domain, you *will* need a cross-domain policy file, so that might not be the immediant problem, but it will be a problem if you don't have the file.

                Also, if you try to load something off a server from local, that is cross-domain, and it is also cross 'sandbox', local-to-network. When testing locally, check your local playback security settings in the Publish Settings to make sure it's allowing network access if you want to connect to a server, or local access if you want to load something locally.
                • 5. Re: Published Audio Not Playing
                  davefc Level 1
                  Thanks for staying with me on this. I understand all your cross-domain comments and will bear them in mind.

                  The remaining important question is: Does Flash 8 plugin support Java servlet GETs for mp3 files? Does anyone know? It does not work for me. The IDE does support them; the plugin does not.

                  In the servlet, I am setting the MIME type and HTTP transaction status:

                  response.setContentType("audio/mpeg");
                  response.setStatus(HttpServletResponse.SC_OK);

                  Are there any other HTTP headers that I need to set, perhaps, so the plugin is comfortable with getting the sound file from a servlet?

                  Any successful examples would be appreciated, or a definitive "can't do that".

                  Thanks!
                  • 6. Re: Published Audio Not Playing
                    davefc Level 1
                    One more data point:

                    It works in FireFox. The problem in only with IE 6.

                    • 7. Re: Published Audio Not Playing
                      abeall Level 3
                      > It works in FireFox. The problem in only with IE 6.

                      Uck. Isn't that fun?

                      Don't get your hopes up, but I have noticed a strange problem with audio in IE, where attempting to load or start a Sound "too quickly" seems to not work. Try adding a delay with setInterval inside the onLoad before the start().

                      var aSound:Sound = new Sound();
                      aSound.onLoad = function(success:Boolean) {
                      if(success) {
                      mx.controls.Alert.show("Audio Loaded Successfully:" +
                      aSound.getBytesLoaded() + ":" + aSound.getBytesTotal());
                      inter = setInterval(aStart,100);
                      }
                      };
                      aSound.loadSound(" http://maniac.ckint.com:19181/quizapp/AudioServlet?InteractionId=1&InteractionItemTypeId=2 ", false);

                      function aStart(){
                      clearInterval(inter);
                      aSound.start();
                      }
                      • 8. Re: Published Audio Not Playing
                        davefc Level 1
                        beally --

                        Thanks for taking this painful journey with me! I tried your delay code and it did not help. The file is loaded, the onLoad is successful, the loaded/total byte counts are correct, but IE is deaf and dumb... FireFox is fine.

                        What do you think about me buying a support call? Is that worth my time and $40? Will they have a solution or known bug for me?

                        Thanks again!

                        Dave
                        • 9. Re: Published Audio Not Playing
                          abeall Level 3
                          I've never done that, so I really don't know if it's worth it. There may be a known bug. If you do go that route, let us know what they suggest.

                          You may have already done this, but try starting that audio a bunch of different ways. For instance:

                          onMouseUp = function(){
                          aSound.start();
                          }

                          Basically, just do crazy stuff to see if you can get it to play in IE. From experience, I can usually find some way to make it work, then I refine that and go with it.

                          If you put a cross-domain policy on the maniac.ckint.com server I'll give it a go.
                          • 10. Re: Published Audio Not Playing
                            davefc Level 1
                            Thanks again, beally. I appreciate your help. I now have a case open with Tech Support.

                            I also tried Netscape browser. The problem is only with IE. Netscape and FireFox work fine.

                            I'll let you know if they can do anything for me. I'll also keep fiddling along the lines you suggest. Thanks again!

                            Dave
                            • 11. Re: Published Audio Not Playing
                              davefc Level 1
                              Good news. Flash Player 9 solves the problem!

                              Yesterday IE prompted me to download Flash Player 9 when I ran my page. I tried for 30 minutes to stop IE from auto-downloading it (as I wanted to stay with a constant dev environment using 8) and finally gave up and loaded 9. Lo and behold, I started hearing my audio playing in IE. Talk about serendipity...

                              Thanks for your help, again, beally.

                              Dave