Hi, i am having some problems linking my mp3 player swf file to my website. It looks like it loads fine, and the buttons work and change the track of the song, but there is no sound heard or played. Here is the code i used to do this:
action script:
var sound_obj = new Sound();
sound_obj.onSoundComplete = playSong;
sound_obj.setVolume(75);
var artist_array = new Array();
var track_array = new Array();
var url_array = new Array();
var current_song = -1;
var pos;
// ----------------------------------------------------------- XML
var xml_obj = new XML();
xml_obj.ignoreWhite = true;
xml_obj.onLoad = function() {
var nodes = this.firstChild.childNodes;
for (var i=0;i<nodes.length;i++) {
artist_array* = nodes*.attributes.artist; //here we need separate arrays for each attribute, and we’re relying on the assumption that if
track_array* = nodes*.attributes.track; //they all share the same index number then we don’t need to keep track of their position
url_array* = nodes*.attributes.url; //the credits.js example from Assignment 2 worked like this
}
playSong();
}
xml_obj.load(“audio/songs.xml”);
// ----------------------------------------------------------- playSong()
function playSong() {
sound_obj = new Sound();
sound_obj.onSoundComplete = playSong;
if (current_song == url_array.length - 1) {
current_song = 0;
sound_obj.loadSound(url_array[current_song], true);
}
else {
current_song = current_song + 1;
sound_obj.loadSound(url_array[current_song], true);
}
trackInfo.text = artist_array[current_song] + " - " + track_array[current_song];
playPause.gotoAndStop(“pause”);
}
// ----------------------------------------------------------- prevSong()
function prevSong() {
sound_obj = new Sound();
sound_obj.onSoundComplete = prevSong;
if (current_song == 0) {
current_song = url_array.length - 1;
sound_obj.loadSound(url_array[current_song], true);
}
else {
current_song = current_song - 1;
sound_obj.loadSound(url_array[current_song], true);
}
trackInfo.text = artist_array[current_song] + " - " + track_array[current_song];
playPause.gotoAndStop(“pause”);
}
// ----------------------------------------------------------- stopSong()
function stopSong() {
sound_obj = new Sound();
sound_obj.onSoundComplete = prevSong;
if (current_song == 0) {
stop();
}
else {
stop();
}
trackInfo.text = artist_array[current_song] + " - " + track_array[current_song];
playPause.gotoAndStop(“pause”);
}
// ----------------------------------------------------------- Pause Functions
function pauseIt() {
pos = sound_obj.position;
sound_obj.stop();
}
function unPauseIt() {
sound_obj.start(pos/1000);
}
// ----------------------------------------------------------- Play/Pause Button
playPause.onRollOver = function() {
if(this._currentframe == 1) {
this.gotoAndStop(“pauseOver”);
}
else {
this.gotoAndStop(“playOver”);
}
}
playPause.onRollOut = function() {
if(this._currentframe == 10) {
this.gotoAndStop(“pause”);
}
else {
this.gotoAndStop(“play”);
}
}
playPause.onRelease = function() {
if(this._currentframe == 10) {
this.gotoAndStop(“playOver”);
_root.pauseIt();
}
else {
this.gotoAndStop(“pauseOver”);
_root.unPauseIt();
}
}
// ----------------------------------------------------------- Next Button
next.onRollOver = function() {
this.gotoAndStop(“nextOver”);
}
next.onRollOut = function() {
this.gotoAndStop(“next”);
}
next.onRelease = function() {
_root.playSong();
}
// ----------------------------------------------------------- Prev Button
prev.onRollOver = function() {
this.gotoAndStop(“prevOver”);
}
prev.onRollOut = function() {
this.gotoAndStop(“prev”);
}
prev.onRelease = function() {
_root.prevSong();
}
// ----------------------------------------------------------- Prev Button
stop_now.onRollOver = function() {
this.gotoAndStop(“prevOver”);
}
stop_now.onRollOut = function() {
this.gotoAndStop(“prev”);
}
stop_now.onRelease = function() {
_root.stopSong();
}
html:
<object data="flash/player.swf" type="application/x-shockwave-flash"
width=“500px” height=“500px”>
<param name=“player” value=“flash/player” />
<param name=“wmode” value=“transparent” />
</object>
As i said before, the player loads up and shows up on the website with no errorsand the buttons work (going to next or previous song as well as the pause and play buttons pausing and playing the music properly), but no sound can be heard. (this is being test on the latest version of firefox).