oldarney
10-28-2005, 11:03 PM
im making a small juke box with a streaming mp3 for a site and well it just wont work i think its some sort of mistake i made but it should be easy. to fix well not easy enough for me to fix
//selection box parameters
//default music
if (selection_box._currentframe == 1) {
url = "music/benny benassi i love my sex.mp3";
}
if (selection_box._currentframe == 5) {
url = "music/benny benassi i love my sex.mp3";
}
if (selection_box._currentframe == 10) {
url = "music/benny benassy satisfaction.mp3";
}
// create sound object, assign events
function createSoundObject() {
soundContainer = new Sound(this);
// define sound object
soundContainer.onSoundComplete = updateStatus;
// change state at song end
return;
}
// create initial sound object
createSoundObject();
prevUrl = null;
// store current url in global variable
isPlaying = false;
// store playstate in global variable
// load and/or play sound
function playSnd(url) {
// check playstate
if (isPlaying) {
return;
// deactivate button during play/load
} else {
isPlaying = true;
}
// check if same or new sound
if (prevUrl != url) {
// new sound
soundContainer.loadSound(url, true);
// sound automatically plays after loading
prevUrl = url;
} else if (soundContainer.position>(soundContainer.duration-100)) {
// same sound
soundContainer.start(0);
// replay from beginning
} else {
// same sound
soundContainer.start(soundContainer.position/1000);
// start sound at last paused
}
onEnterFrame = showPlayState;
// start tracking playstate
}
// stop both playback and download
function stopSnd() {
soundContainer.stop();
// stop playback
delete soundContainer;
// stop download
createSoundObject();
// create a new sound object
isPlaying = false;
prevUrl = "";
// clear for next load
onEnterFrame = null;
// stop tracking playstate
status = "stopped";
}
// store state and show status at end of song
function updateStatus() {
isPlaying = false;
onEnterFrame = null;
// stop tracking playstate
status = "complete";
}
// show playback and load status
function showPlayState() {
// use Number function to convert undefined values to 0
var sndPos = Number(soundContainer.position);
var loaded = (Number(soundContainer.getBytesTotal()>0) && Number(soundContainer.getBytesLoaded()) == Number(soundContainer.getBytesTotal()));
if (sndPos<=prevPos && !loaded) {
// loading
status = "loading";
} else {
// playing
status = "playing";
}
prevPos = sndPos;
// store for next loop
}
prevPos = 0;
// store last position in global variable
// store state and show status at end of song
function updateStatus() {
isPlaying = false;
onEnterFrame = null;
// stop tracking playstate
status = "complete";
}
// pause sound
function pauseSnd() {
soundContainer.stop();
isPlaying = false;
onEnterFrame = null;
// stop tracking playstate
status = "paused";
}
// stop sound reset position to begining
function rewindSnd() {
soundContainer.stop();
// stop current playback
soundContainer.start(0);
// reset position to 0
soundContainer.stop();
// prevent imediate playback
isPlaying = false;
onEnterFrame = null;
// stop tracking playstate
status = "rewound";
}
// assign button events
play_Btn.onRelease = function() {
playSnd(url);
};
stop_Btn.onRelease = stopSnd;
pauseBtn.onRelease = pauseSnd;
rewindBtn.onRelease = rewindSnd;
if you hapend to have a computer with out one single song to test the script
here is one of my favs
http://www6.rapidupload.com/download.php?file=dl&filepath=138
here is the web site im doing
my page (http://promocionelectro.50megs.com/)
//selection box parameters
//default music
if (selection_box._currentframe == 1) {
url = "music/benny benassi i love my sex.mp3";
}
if (selection_box._currentframe == 5) {
url = "music/benny benassi i love my sex.mp3";
}
if (selection_box._currentframe == 10) {
url = "music/benny benassy satisfaction.mp3";
}
// create sound object, assign events
function createSoundObject() {
soundContainer = new Sound(this);
// define sound object
soundContainer.onSoundComplete = updateStatus;
// change state at song end
return;
}
// create initial sound object
createSoundObject();
prevUrl = null;
// store current url in global variable
isPlaying = false;
// store playstate in global variable
// load and/or play sound
function playSnd(url) {
// check playstate
if (isPlaying) {
return;
// deactivate button during play/load
} else {
isPlaying = true;
}
// check if same or new sound
if (prevUrl != url) {
// new sound
soundContainer.loadSound(url, true);
// sound automatically plays after loading
prevUrl = url;
} else if (soundContainer.position>(soundContainer.duration-100)) {
// same sound
soundContainer.start(0);
// replay from beginning
} else {
// same sound
soundContainer.start(soundContainer.position/1000);
// start sound at last paused
}
onEnterFrame = showPlayState;
// start tracking playstate
}
// stop both playback and download
function stopSnd() {
soundContainer.stop();
// stop playback
delete soundContainer;
// stop download
createSoundObject();
// create a new sound object
isPlaying = false;
prevUrl = "";
// clear for next load
onEnterFrame = null;
// stop tracking playstate
status = "stopped";
}
// store state and show status at end of song
function updateStatus() {
isPlaying = false;
onEnterFrame = null;
// stop tracking playstate
status = "complete";
}
// show playback and load status
function showPlayState() {
// use Number function to convert undefined values to 0
var sndPos = Number(soundContainer.position);
var loaded = (Number(soundContainer.getBytesTotal()>0) && Number(soundContainer.getBytesLoaded()) == Number(soundContainer.getBytesTotal()));
if (sndPos<=prevPos && !loaded) {
// loading
status = "loading";
} else {
// playing
status = "playing";
}
prevPos = sndPos;
// store for next loop
}
prevPos = 0;
// store last position in global variable
// store state and show status at end of song
function updateStatus() {
isPlaying = false;
onEnterFrame = null;
// stop tracking playstate
status = "complete";
}
// pause sound
function pauseSnd() {
soundContainer.stop();
isPlaying = false;
onEnterFrame = null;
// stop tracking playstate
status = "paused";
}
// stop sound reset position to begining
function rewindSnd() {
soundContainer.stop();
// stop current playback
soundContainer.start(0);
// reset position to 0
soundContainer.stop();
// prevent imediate playback
isPlaying = false;
onEnterFrame = null;
// stop tracking playstate
status = "rewound";
}
// assign button events
play_Btn.onRelease = function() {
playSnd(url);
};
stop_Btn.onRelease = stopSnd;
pauseBtn.onRelease = pauseSnd;
rewindBtn.onRelease = rewindSnd;
if you hapend to have a computer with out one single song to test the script
here is one of my favs
http://www6.rapidupload.com/download.php?file=dl&filepath=138
here is the web site im doing
my page (http://promocionelectro.50megs.com/)