Hi, I am new to this site. I am working on a website where users can upload music to be rated by other users. I recently discovered a problem where the song duration doesn't appear correctly if the user's computer hasn't streamed that particular song before. It will play with the incorrect song duration displayed and then once the song has been loaded fully, the correct information appears and the song starts over. You can view the site here www.songfeedback.com and login with username 'tester' and password 'tester' so you dont have to register. I posted the functions that deal with the time display. I can post more if needed. Thanks! Chris
This code just selects the song that will play (this code is only showing 1 out of the 15 songs on the list)
Actionscript Code:
//initiate sound
var sound1 = new Sound();
//select song
_root.list1.onRelease = function(){
playertitle = title1;
playerartist = artist1;
currentfile = filename1;
artistcom = artistcom1;
sound1.loadSound("uploads/"+filename1, true);
sound1.onLoad = function(){
sound1.start();
sound1playing = true;
_root.soundicon.gotoAndStop(1);
durpos ();
}
}
This all runs once a song has been selected:
Actionscript Code:
//song time
function durpos () {
cont1 = false;//these reset some buttons when a new song is selected
cont2 = false;
cont3 = false;
cont4 = false;
cont5 = false;
cont6 = false;
cont7 = false;
cont8 = false;
cont9 = false;
cont10 = false;
submitted = 0;
_root.resetme = 1;
commentz.currentfile = currentfile;//these two lines load the comments section for the song playing
commentz.sendAndLoad("comment.php", commentz, "POST");
//get the total time for the song
soundpos = sound1.duration/1000;
minutesTotal = Math.floor(soundpos / 60);
secondsTotal = Math.floor(soundpos-minutesTotal*60);
if (secondsTotal <= 9){
totaltime = "/ " + minutesTotal + ":0" + secondsTotal;
}
else{
totaltime = "/ " + minutesTotal + ":" + secondsTotal;
}
}
var doInterval;
doInterval = setInterval(pos,100);
function pos () {
soundposition = sound1.position/1000;
seconds = Math.floor((sound1.position/1000)%60);
minutes = Math.floor((sound1.position/1000)/60);
if (isNaN(seconds)){
timegone = "0:00";
}
else if (seconds <= 9){
timegone = minutes + ":0" + seconds;
}
else{
timegone = minutes + ":" + seconds;
}
//submittal permission
halfway = soundpos/2;
if (soundposition > halfway && _root.submitted == 0){
_root.ratebutton._x= 501;
}
else{
_root.ratebutton._x = 600;
}
}