View Full Version : Problem with sound duration
asthyanax
November 30th, 2004, 11:08 AM
Hi,
i have a mp3 player that works perfectly offline but once online the sound.duration seems to be incorrect. The sound.duration = 15' online and 52' offline. And it's the same for each mp3 with an incorrect duration.
You can see what i mean here :
http://adesign.tonsite.biz/v4
Any ideas ?
Thank's.
Chris
RvGaTe
November 30th, 2004, 12:05 PM
maybe becoz you stream it?
asthyanax
November 30th, 2004, 01:34 PM
Sorry, what do yo mean by streaming. ?
here my code :
//defines a new sound object
music = new Sound(this);
trkInfo = new Date();
//comment these three lines if you don't want it to play on startup
playing = false;
paused = false;
loading = true;
function select(){
for(i in playlist_mc.target_mc){
if(playlist_mc.target_mc[i].songNum != songNum){
playlist_mc.target_mc[i].gotoAndStop(1);
}
else{
playlist_mc.target_mc[i].gotoAndStop(2);
}
}
}
songNum = 0;
numTracks = songInfo.content.length;
for(i = 0; i < numTracks; i++){
songInfo.content[i].songNum = i;
playlist_mc.target_mc.attachMovie("playlistItem", "item" + i, (i+1), songInfo.content[i]);
playlist_mc.target_mc["item" + i]._y = i * 18;
if(playlist_mc.target_mc["item" + i].title == songInfo.content[songNum].title){
playlist_mc.target_mc["item" + i].gotoAndStop(2);
}
else{
playlist_mc.target_mc["item" + i].gotoAndStop(1);
}
}
music.loadSound(songInfo.content[songNum].path, false);
function fadeOut() {
if (music.getVolume()>0) {
music.setVolume(music.getVolume()-5);
} else {
music.stop();
}
}
function nextSong(){
if(loop == true and skipLoop != true){
music.stop();
music.start();
}
else{
if(shuffle == true){
songNum = Math.floor(Math.random()*(numTracks-1));
}
else{
songNum++;
if(songNum == songInfo.content.length){
songNum = 0;
}
}
loading = true;
playing = false;
paused = false;
select();
if(skipLoop == true){
skipLoop = false;
}
music.loadSound(songInfo.content[songNum].path, false);
}
}
function prevSong(){
songNum--;
if(songNum < 0){
songNum = songInfo.content.length - 1;
}
loading = true;
playing = false;
paused = false;
select();
music.loadSound(songInfo.content[songNum].path, false);
}
this.onEnterFrame = function() {
dur = music.duration;
pos = music.position;
total = music.getBytesTotal();
loaded = music.getBytesLoaded();
ratio=(loaded/total) * 100;
//preloader
if (loading == true) {
if (music.getBytesLoaded() == music.getBytesTotal() and dur > 0){
barre._visible=false;
barre._xscale=0;
loading = false;
playing = true;
music.start();
status = "playing";
}
else{
barre._visible=true;
barre._xscale=ratio;
status = "loading";
}
}
else if (playing == true) {
vol = music.getVolume() + "%";
bal = music.getPan();
music.onSoundComplete = nextSong;
} else{
fadeOut();
status = "stopped";
}
if(timeWay == "forward" or timeWay == undefined){
trkInfo.setSeconds(music.position/1000);
trkInfo.setMinutes((music.position/1000)/60);
trkInfo.setHours((music.position/1000)/3600);
}
else{
trkInfo.setSeconds((music.duration -music.position)/1000);
trkInfo.setMinutes(((music.duration -music.position)/1000)/60);
trkInfo.setHours(((music.duration -music.position)/1000)/3600);
}
seconds = trkInfo.getSeconds();
minutes = trkInfo.getMinutes();
hours = trkInfo.getHours();
if(seconds < 10){
seconds = 0 + seconds.toString();
}
if(minutes < 10){
minutes = 0 + minutes.toString();
}
if(hours < 10){
hours = 0 + hours.toString();
}
trkHrs = Math.floor((music.duration/1000)/3600);
trkMin = Math.floor((music.duration/1000)/60);
trkSec = Math.floor((music.duration/1000) - (60*trkMin));
if(trkSec < 10){
trkSec = 0 + trkSec.toString();
}
if(trkMin < 10){
trkMin = 0 + trkMin.toString();
}
if(trkHrs < 10){
trkHrs = 0 + trkHrs.toString();
}
if(loading != true){
time = minutes + ":" + seconds;
}
else{
time = "00:00";
}
};
play_mc.onRelease = play_mc.onReleaseOutside = function() {
if(playing != true or paused == true){
if(loading != true){
if(paused == true){
seconds = pos/1000;
music.start(seconds, 0);
paused = false;
}
else if (loading != true) {
loading = true;
music.loadSound(songInfo.content[songNum].path, false);
}
}
}
};
stop_mc.onRelease = stop_mc.onReleaseOutside = function () {
loading =false;
playing = false;
paused = false;
if(barre._visible){
barre._visible=false;
}
};
pause_mc.onRelease = pause_mc.onReleaseOutside = function(){
if(playing == true){
if(paused == false){
pos = music.position;
music.stop();
paused = true;
}
else{
seconds = pos/1000;
music.start(seconds, 0);
paused = false;
}
}
}
next_mc.onRelease = next_mc.onReleaseOutside = function(){
if(loading != true){
skipLoop = true;
nextSong();
}
}
back_mc.onRelease = back_mc.onReleaseOutside = function(){
if(loading != true){
prevSong();
}
}
barre._visible=false;
stop();
And before that i load an xml file.
Thank's a lot.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.