Musicman to the rescue? :)
Hi Musicman,
I hate to bother you but I've been following alot of your sound advice on this board (no pun intended) and have been unsuccesful in accomplishing what I am trying to do.
I bought a magazine that has a tutorial and a .fla for a php driven flash player. The problem is that the entire code is setup for a dynamic playlist, and in my situation I will only have one song per page. I am sending the variables to Flash like this:
...<param name="movie" value="player.swf<?php echo "?mp3_path=$mp3&stitle=$stitle" ?>">...
and
...<embed src="player.swf<?php echo "?mp3_path=$mp3&stitle=$stitle" ?>"...
What I need to know is how would I change the following code to reflect that? Their code is chuck full of functions for changing to the next track and prev track, etc and it's way over my head. I would like to keep the normal id3 and play type functions but lose all of the multiple track info. If anybody could help on this I would really appreciate it. I got in trouble right from the start because this code tries to call the mp3 path variable from a php file but it doesnt need to because I am assigning it with the above code. The nunomira page says that I can access the variables in Flash with this:
trace(_level0.mp3_path);
Do I need to trace the variable or can I just use
mp3=(_level0.mp3_path); ?
Here is the raw code that I need to somehow strip down to just a one song script. Thank you VERY MUCH for any advice or help.
lv = new LoadVars();
lv.onLoad = function()
{
mp3list = new Array();
var i = 0;
while (this["file" + i] != undefined)
{
mp3list[i] = this["file" + i];
i++;
}
}
lv.load("getmp3s.php");
volumeB.stop();
volumeB.onPress = function()
{
this.gotoAndStop(3);
this.startDrag(false, this._x, 29, this._x, 144);
volumeB.onMouseMove = function()
{
mp3Sound.setVolume(100 - ((this._y - 29) / 115) * 100);
}
}
volumeB.onRelease = volumeB.onReleaseOutside = function()
{
this.gotoAndStop(1);
this.stopDrag();
}
function loadTrack(fname)
{
mp3Sound = new Sound();
mp3Sound.loadSound(fname, true);
mp3Sound.onID3 = function()
{
textString = this.id3.track + ". " + this.id3.songname + " (c)" + this.id3.year + " - " + this.id3.artist + " - " + this.id3.album + " ";
tracktitle.text = textString;
}
mp3Sound.onSoundComplete = nextTrack;
tracktitle.text = fname;
tracktime.text = "0:00";
}
currentTrack = -1;
function nextTrack()
{
clearInterval(playback);
playback = setInterval(refreshDisplay, 250);
wrap = 0;
currentTrack++;
currentTrack%=mp3list.length;
loadTrack(mp3list[currentTrack]);
}
function prevTrack()
{
clearInterval(playback);
playback = setInterval(refreshDisplay, 250);
wrap = 0;
currentTrack--;
if (currentTrack < 0) currentTrack = mp3list.length-1;
loadTrack(mp3list[currentTrack]);
}
function stopTrack()
{
stoppos = mp3Sound.position;
mp3Sound.stop();
}
function resumeTrack()
{
if (stoppos == undefined)
{
nextTrack();
}
else
mp3Sound.start(stoppos / 1000);
}
function rewindTrack()
{
pos = mp3Sound.position;
pos -= 2000;
if (pos < 0) pos = 0;
mp3Sound.start(pos / 1000);
}
//nextTrack();
nextTrackButton.onRelease = nextTrack;
prevTrackButton.onRelease = prevTrack;
stopButton.onRelease = stopTrack;
playButton.onRelease = resumeTrack;
rewindButton.onRelease = rewindTrack;
progressb.inner._width = 0;
refreshDisplay = function()
{
tracktitle.text = textString.substr(wrap, textString.length) + textString;
wrap++;
wrap %= textString.length;
var pos = Math.floor(mp3Sound.position / 1000);
sec = (pos % 60).toString();
min = Math.floor(pos / 60).toString();
if (sec.length == 1) sec = "0" + sec;
tracktime.text = min + ":" + sec;
progressb.inner._width = (mp3Sound.position / mp3Sound.duration) * 250;
}