|
| Hi,
I have an mp3 player which plays the mp3 for the whole song but I only want it
to play so many seconds of the file. How I do this?
Someone has suggested a loop that continually checks the sound.position
property giving the number of milliseconds that the sound has been playing and
when it reaches your required number and it will stop by using - song.stop();
Being a noob in this side of flash , can anyone actually help me out here?
Part of the current code is below..
Thanks,
Rock
---snipped above
// [Action in Frame 15]
song.start(pausePos, 100);
nowplay = _root.curentTrack;
previousT = _root.curentTrack;
_root.nextsong = ++nowplay;
_root.previousTrack = --previousT;
// [Action in Frame 16]
total_bytes = song.getBytesTotal();
loaded_bytes = song.getBytesLoaded();
remaining_bytes = total_bytes - loaded_bytes;
percent_done = int(loaded_bytes / total_bytes * 100);
loaded.gotoAndStop(percent_done);
timos = _root.song.duration;
pos = new Date();
pos.setSeconds(song.position / 1000);
pos.setMinutes(song.position / 1000 / 60);
pos.setHours(song.position / 1000 / 120);
seconds = pos.getSeconds();
minutes = pos.getMinutes();
hours = pos.getHours();
if (seconds < 10)
{
seconds = 0 + seconds.toString();
} // end if
if (minutes < 10)
{
minutes = 0 + minutes.toString();
} // end if
if (hours < 10)
{
hours = 0 + hours.toString();
} // end if
time = hours + ":" + minutes + ":" + seconds;
// [Action in Frame 17]
if (Playing == true)
{
gotoAndPlay("loop");
}
else
{
gotoAndStop("player");
} // end if
song.onSoundComplete = function ()
{
if (_root.loops == true)
{
_root.gotoAndPlay("nowplaying");
}
else
{
nextToplay = _root["trck" + _root.nextsong];
trackos = _root.path + "/" + nextToplay;
_root.song.stop();
delete _root["song"];
_root.song = new Sound();
_root.song.loadSound(trackos, true);
_root.song.attachSound("loop");
_root.pausePos = false;
_root.Playing = true;
_root.Stop = false;
_root.curentTrack = _root.nextsong;
_root.previousTrack = --_root.nextsong;
_root.pl_scroller.spContentHolder["track_pl" +
_root.previousTrack].track_name.textColor = 0;
_root.pl_scroller.spContentHolder["track_pl" +
_root.curentTrack].track_name.textColor = 16777215;
_root.titleT = _root["trck" + _root.curentTrack].slice(0, -4);
_root.gotoAndPlay("nowplaying");
} // end if
|
|