Skip to main content
January 10, 2010
Question

MP3 Player - no sound through web server

  • January 10, 2010
  • 1 reply
  • 2406 views

Hi Everyone,

I created a simple MP3 player with ActionScript 3.0, using sound classes, and put it into a webpage.  I test my webpages using the following 5 browsers: IE, Firefox, Safari, Opera and Google.  I have Apache and PHP servers loaded onto my computer to test my .php pages.

Here is the issue I am running into: When I test to MP3 player (in an .html file) in all five browers and access the .html file through the C drive the MP3 player works well in all five browsers.  HOWEVER, when I access the .html file from my web server the MP3 player works in IE, Google and Safaris, but NOT in Firefox and Opera.  For Firefox and Opera it will not play, no sound, but the rest of the functionality works. 

I've done a lot of troubleshooting, such as uploading the files to my web hosting service and I get the same results.  I tried messing around with publishing settings in Flash, but nothing seemed to help.  I verified that all five browsers are using Flash Player 10.  I've tired the MP3 player in a .php file and a couple of more things. 

Does anyone have any idea why the MP3 player works in Firefox and Opera when I access the .html file from my C drive, but NOT when I try the MP3 player though a web server?  Remember, the MP3 player works just fine through the web server with IE, Safari and Google.

Here is the Actionscript 3.0 coding:

import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundMixer;

var my_songs:XMLList;
var my_total:Number;
var my_sound:Sound;
var my_channel:SoundChannel;
var current_song:Number = 0;
var song_position:Number;
var song_paused:Boolean;

var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("christmas.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(e:Event):void
{
    var myXML:XML = new XML(e.target.data);
    my_songs = myXML.SONG;
    my_total = my_songs.length();
   
    myXMLLoader.removeEventListener(Event.COMPLETE, processXML);
    myXMLLoader = null;
}

function playSong(mySong:Number):void
{
    var myTitle = my_songs[mySong].@title;
    var myArtist = my_songs[mySong].@artist;
    var myURL = my_songs[mySong].@URL;
    var myLength = my_songs[mySong].@length;
    title_txt.text = myTitle;
    artist_txt.text = myArtist;
    length_txt.text = myLength;
    if (my_channel)
    {
    my_channel.stop();
    my_channel.removeEventListener(Event.SOUND_COMPLETE, onNext);
    }
   
    my_sound = new Sound();
    my_sound.load(new URLRequest(myURL));
    my_channel = my_sound.play();
    my_channel.addEventListener(Event.SOUND_COMPLETE, onNext);
}

next_btn.addEventListener(MouseEvent.CLICK, onNext);
function onNext(e:Event):void
{
    current_song++;
   
    if (current_song>=my_total)
    {
       current_song=0;
    }
   
    playSong(current_song);
}

prev_btn.addEventListener(MouseEvent.CLICK, onPrev);
function onPrev(e:MouseEvent):void
{
   current_song--;
     if (current_song<0)
     {
       current_song = my_total-1;
     }
   playSong(current_song);
}

pause_btn.addEventListener(MouseEvent.CLICK, onPause);
function onPause(e:MouseEvent):void
{
    if (my_channel)
    {
    song_position = my_channel.position;
    my_channel.stop();
    song_paused=true;
    }
}

play_btn.addEventListener(MouseEvent.CLICK, onPlay);
function onPlay(e:MouseEvent):void
{
    if (song_paused)
    {
    my_channel = my_sound.play(song_position);
    song_paused=false;
    }
    else if (!my_channel)
    {
    playSong(current_song);
    }
}

Thanks!

Julie Rapport

Training to be an RIA Developer

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
January 11, 2010

what's the url to your swf's embedding html?

January 11, 2010

Hi KGlad,

The URL is: http://www.walnuttreefalls.com/testing.html

Thanks,

Julie

kglad
Community Expert
Community Expert
January 11, 2010

test using the html published by flash.  any problem?