3 Replies Latest reply on Sep 30, 2010 3:04 PM by Aduen

    MP3 file does not load in Google Chrome and Safari, works in FireFox and IE6

    Aduen Level 1

      I'm loading a simple MP3 file using this elaborated set up


      private var snd_player : MediaPlayer;
      var container : MediaContainer = new MediaContainer();
      // Create the resource to play
      var resource : URLResource = new URLResource("../sounds/scramble.mp3");
      // Create a mediafactory instance
      var mediaFactory : DefaultMediaFactory = new DefaultMediaFactory();
      // Create the MediaElement and add it to our container class.
      var myMediaElement : MediaElement = mediaFactory.createMediaElement(resource);
      // Create a media player
      snd_player = new MediaPlayer();
      // Stop from autoplaying
      snd_player.autoPlay = false; 
      // Then assign the media
      snd_player.media = myMediaElement;
      snd_player.volume = 0.7;
      snd_player.autoRewind = true;
      snd_player.loop = true;


      if also tried this set up:


      private var snd_player : MediaPlayer;
      private var sound_over : AudioElement;
      sound_over = new AudioElement();
      sound_over.resource = new URLResource("../sounds/scramble.mp3");
      var fact:MediaFactory = new MediaFactory();
      MonsterDebugger.trace(this, fact.createMediaElement(sound_over.resource));
      snd_player = new MediaPlayer();
      snd_player.addEventListener(MediaErrorEvent.MEDIA_ERROR, debug);
      snd_player.addEventListener(LoadEvent.LOAD_STATE_CHANGE, debug);
      snd_player.addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, debug);
      snd_player.addEventListener(MediaPlayerCapabilityChangeEvent.TEMPORAL_CHANGE, debug);
      snd_player.addEventListener(MediaPlayerCapabilityChangeEvent.HAS_DRM_CHANGE, debug);
      snd_player.media = sound_over;
      snd_player.volume = 0.7;
      snd_player.autoRewind = true;
      snd_player.autoPlay = false;
      snd_player.loop = true;


      using the debugger, the state it returns is "loading". But no bytes are loaded, bytesloaded remains 0.


      this only happens in the mentioned browsers (chrome and safari), both setups work in FF and IE


      Does someone know what I am missing here?

        • 1. Re: MP3 file does not load in Google Chrome and Safari, works in FireFox and IE6
          Aduen Level 1

          made a small prototype:




          click the flash button, loads in a sound using all native flash

          click the osmf button, does osmf loading and playing,


          code posted below


          test it in various browser yourself, it does not work in Chrome and Safari




          package {
               import org.osmf.elements.AudioElement;
               import org.osmf.media.MediaPlayer;
               import org.osmf.media.URLResource;
               import flash.display.Sprite;
               import flash.events.MouseEvent;
               import flash.media.Sound;
               import flash.media.SoundChannel;
               import flash.media.SoundLoaderContext;
               import flash.media.SoundTransform;
               import flash.net.URLRequest;
                * @author Aduen
               public class Main extends Sprite {
                    public var osmf_btn:Sprite;
                    public var flash_btn:Sprite;
                    private var sound_click:AudioElement;
                    private var snd_player:MediaPlayer;
                    private var sound_chn:SoundChannel;
                    private var sound_tran:SoundTransform;
                    private var sound_over:Sound;
                    public function Main() {
                         osmf_btn.buttonMode = true;
                         flash_btn.buttonMode = true;
                         osmf_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler);
                         flash_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler);
                         sound_click = new AudioElement();
                      sound_click.resource = new URLResource("HTTP://ui.aduen.nl/sounds/button_click.mp3");
                         snd_player = new MediaPlayer();
                         snd_player.volume = 0.7;
                         snd_player.autoRewind = true;
                         snd_player.autoPlay = false;
                         snd_player.loop = false;
                         snd_player.media = sound_click;
                         sound_tran = new SoundTransform(0.7);
                         sound_over = new Sound(new URLRequest("HTTP://ui.aduen.nl/sounds/button_over.mp3"), new SoundLoaderContext(100));
                    private function mouseHandler(e : MouseEvent) : void {
                              case osmf_btn:
                              case flash_btn:
                                   sound_chn = sound_over.play(0, 0, sound_tran);
          • 3. Re: MP3 file does not load in Google Chrome and Safari, works in FireFox and IE6
            Aduen Level 1

            Thanks, I am looking forward to solution.