Can someone please lend me a hand...tried just about everything I can think of.
I made a button to control the option of "continuous" called btob_btn but can't get it to function correctly.
My original play function had a 'nextTrack' variable in it, after removing it and putting a 'stop ()'..it worked fine. Now I can't figure out how to implement the "nextTrack ()" into the btob_btn to be able to control "continuous".
Here is the code:
Code:
MySound.onSoundComplete=function(){
if (playrepeat) {
playSong();
if (continuous) {
playSong();
nextTrack();
}
stop ()
}
}
// Back to Back
btob_btn.onRelease = function() {
continuous = !continuous;
}
btob_btn.onRollOver = function() {
status = "Status: Play tracks back to back";
}
btob_btn.onRollOut = function() {
status = (playSignal) ? status = "Status: playing" : status = "Status: stopped";
}
I'm not sure if that will help but anyway I've recreated part of script and made a test, just download the .fla add 3 sounds into your library and link them as audio1, audio2, audio3, and that's all!
Here is the original code for the play function. On soundComplete it is automatically advancing to the next track (from a dynamically loaded xml playlist).
What I want is to:
A. Have the tracks play only once without advancing.
B. Have a "continuous button" that will have the tracks advance automatically
Then I believe you need just one variable,but before everything else like pointed by Robb@exo, did you defined the var continuous? If not, you need to:
var continuous:Boolean = false;
Then, what do you need that playrepeat for? I suppose yo just need continuous to be set.
Another problem might be that you call two functions at the same time, I mean perhaps it tries to play the next track before actually moving to it, so try to move the playSong() within the nextTrack function.
If you still have problems, well it might be a good idea to post your entire code or the .fla so that we could give a better look!
"play" play a single song in the playlist
"playrepeat" to play a single track over and over again
"continuous" to play and continue to the next track in playlist order
Here is all the code:
Code:
stop();
// XML (Playlist + Administration)
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = ladeDaten;
data_xml.load(playlist);
function ladeDaten(success) {
if (success) {
aPath = new Array();
songTitel = new Array();
songArtist = new Array();
songCover = new Array();
audioTracks = new Array();
audioTracks = this.firstChild.childNodes;
totalAudio = audioTracks.length;
for (var i=0; i<totalAudio; i++) {
if (audioTracks[i].nodeName == "song") {
aPath.push(audioTracks[i].attributes.path);
songTitel.push(audioTracks[i].attributes.title);
songArtist.push(audioTracks[i].attributes.artist);
songCover.push(audioTracks[i].attributes.bild);
}
}
AudioPath = aPath[0];
titel = songTitel[0];
artist = songArtist[0];
aktAudio = 1;
trackAnzeige = aktAudio+" / "+totalAudio;
status = "Status: playlist - Loaded";
if (playerlook) setCover(0);
erstesBild = true;
setzeDirektwahl();
setzePlaylistwahl();
if (playatstart) playSong();
} else {
status = "Status: PlayList - Not loaded";
}
delete audioTracks;
delete data_xml;
}
// Cover Loader
function setCover(pNr) {
if (_currentframe == 2 || !erstesBild) {
cover_mc.loadMovie(songCover[pNr],1);
}
}
// Backward
function ruck(diff) {
pausgabe = MySound.position - diff;
MySound.stop();
MySound.start(pausgabe/1000,0);
}
// Forward
function vor(diff) {
pausgabe = MySound.position + diff;
MySound.stop();
MySound.start(pausgabe/1000,0);
}
// Volume and Balance Initial values
volume = 100;
balance = 0;
// Play Function
function playSong() {
if (pauseSignal == true) {
MySound.start(pausePos, 0);
pauseSignal = false;
playSignal = true;
delete pausePos;
kugel_mc._visible = 1;
} else {
MySound = new Sound();
if (volstatus < volume) {
volume = volstatus;
} else if (volstatus > volume) {
volume = volstatus;
} else if (volstatus == 100) {
volume = 100;
}
if (balstatus < balance) {
balance = balstatus;
} else if (balstatus > balance) {
balance = balstatus;
} else if (balstatus == 0) {
balance = 0;
}
MySound.loadSound(AudioPath, StreamSignal);
MySound.setVolume(volume);
MySound.setPan(balance);
MySound.onSoundComplete=function(){
if (playrepeat) {
playSong();
if (continuous) {
nextTrack();
}
stop ()
}
}
volstatus = volume;
balstatus = balance;
pauseSignal = false;
playSignal = true;
wahlSignal = false;
_parent.onEnterFrame = function() {
total = MySound.getBytesTotal();
geladen = MySound.getBytesLoaded();
if (geladen != total) {
if (geladen != undefined && total != undefined) {
status = "Status: " + Math.round((geladen*100/total)) + "% loaded";
}
mc._xscale = Math.round((geladen*100/total));
} else {
status = "Status: playing -100% Loaded";
delete _parent.onEnterFrame;
kugel_mc._visible = 1;
if (!StreamSignal) {
MySound.start(0, 0);
}
}
}
}
}
// Play Button
play_btn.onRelease = function() {
playSong();
}
play_btn.onRollOver = function() {
status = "Status: load / play song";
}
play_btn.onRollOut = function() {
status = (playSignal) ? status = "Status: playing" : status = "Status: stopped";
}
// Continuous Function
var continuous:Boolean = false;
// Continuous Button
btob_btn.onRelease = function() {
var continuous:Boolean = true;
}
btob_btn.onRollOver = function() {
status = "Status: Continuous Play";
}
btob_btn.onRollOut = function() {
status = (playSignal) ? status = "Status: playing" : status = "Status: stopped";
}
// Stop Button
stop_btn.onRelease = function() {
MySound.stop();
playSignal = 0;
delete pausePos;
kugel_mc._visible = 0;
}
stop_btn.onRollOver = function() {
status = "Status: stop playing";
}
stop_btn.onRollOut = function() {
status = (!playSignal) ? status = "Status: stopped" : status = "Status: playing";
}
// Pause Button
pause_btn.onRelease = function() {
if (!wahlSignal) {
pausePos = MySound.position/1000;
MySound.stop();
pauseSignal = true;
playSignal = false;
kugel_mc._visible = 0;
status = "Status: press play";
}
}
pause_btn.onRollOver = function() {
status = (!pauseSignal) ? status = "Status: pause playing" : status = "Status: press play";
}
pause_btn.onRollOut = function() {
status = (!playSignal) ? status = "Status: stopped" : status = "Status: playing";
}
// Next Button
function nextTrack() {
if (aktAudio<totalAudio) {
aktAudio +=1;
AudioPath = aPath[aktAudio-1];
titel = songTitel[aktAudio-1];
artist = songArtist[aktAudio-1];
MySound.stop();
playSignal = 0;
pauseSignal = 0;
wahlSignal = 1;
delete pausePos;
kugel_mc._visible = 0;
trackAnzeige = aktAudio+" / "+totalAudio;
status = "Status: stopped - press play";
setCover(aktAudio-1);
}
}
next_btn.onRelease = function() {
if (aktAudio < totalAudio) {
nextTrack()
playSong();
}
}
next_btn.onRollOver = function() {
dstatus = status;
status = "Status: load next song";
}
next_btn.onRollOut = function() {
if (status != "Status: stopped - press play") status = dstatus;
}
// Previous Button
function prevTrack() {
if (aktAudio>1) {
aktAudio -= 1;
AudioPath = aPath[aktAudio-1];
titel = songTitel[aktAudio-1];
artist = songArtist[aktAudio-1];
MySound.stop();
playSignal = 0;
pauseSignal = 0;
wahlSignal = 1;
delete pausePos;
kugel_mc._visible = 0;
trackAnzeige = aktAudio+" / "+totalAudio;
status = "Status: stopped - press play";
setCover(aktAudio-1);
}
}
prev_btn.onRelease = function() {
if (aktAudio > 1) {
prevTrack();
playSong();
}
}
prev_btn.onRollOver = function() {
dstatus = status;
status = "Status: load prev song";
}
prev_btn.onRollOut = function() {
if (status != "Status: stopped - press play") status = dstatus;
}
// Time Button
zeit_btn.onRelease = function() {
zeitSignal = !zeitSignal;
}
zeit_btn.onRollOver = function() {
dstatus = status;
status = "Status: Total / " +t_TrackZeit.total +" - switch timedisplay ";
}
zeit_btn.onRollOut = function() {
status = dstatus;
}
// Drag Button
drag_btn.onPress = function() {
startDrag(this._parent, false);
}
drag_btn.onRelease = drag_btn.onReleaseOutside = function() {
stopDrag();
}
drag_btn.onRollOver = function() {
dstatus = status;
status = "Status: drag 'n' drop";
}
drag_btn.onRollOut = function() {
status = dstatus;
}
// Look Button
look_btn.onPress = function() {
if (_currentFrame == 2) {
cover_mc._visible = 0;
gotoAndStop(3);
} else {
cover_mc._visible = 1;
gotoAndStop(2);
setzeDirektwahl();
setzePlaylistwahl();
setCover(aktAudio-1);
}
}
look_btn.onRollOver = function() {
dstatus = status;
status = "Status: change look - simple/extended";
}
look_btn.onRollOut = function() {
status = dstatus;
}
// Credits/Logo Schalter
fslogo_btn.onPress = function() {
fslogo_mc._visible = !fslogo_mc._visible;
}
fslogo_btn.onRollOver = function() {
dstatus = status;
status = "Status: player - credits";
}
fslogo_btn.onRollOut = function() {
status = dstatus;
}
// Credits/Logo Clip (Starting situation)
fslogo_mc._visible = 0;
fslogo_mc.onRelease = function() {
getURL("http://www.flashstar.de","_blank");
}
// Equalizer Button
kugel_mc._visible = 0;
// Display
onEnterFrame = function () {
_global.dauer = int(MySound.duration/1000);
_global.position = int(MySound.position/1000);
// Total Time
t_TrackZeit = {};
t_TrackZeit.minutes = int(_global.dauer/60);
t_TrackZeit.seconds = int(_global.dauer%60);
t_TrackZeit.total = checkDigits(t_TrackZeit.minutes)+":"+ checkDigits(t_TrackZeit.seconds);
// Bereits
b_TrackZeit = {};
b_TrackZeit.minutes = int((_global.position)/60);
b_TrackZeit.seconds = int((_global.position)%60);
b_TrackZeit.total = checkDigits(b_TrackZeit.minutes)+":"+ checkDigits(b_TrackZeit.seconds);
// Noch zu Spielen
n_TrackZeit = {};
n_TrackZeit.minutes = int((_global.dauer - _global.position )/ 60);
n_TrackZeit.seconds =int(( _global.dauer - _global.position )%60);
n_TrackZeit.total = checkDigits(n_TrackZeit.minutes)+":"+ checkDigits(n_TrackZeit.seconds);
// Ausgabe
sBalken("smc");
if (zeitSignal) {
display =n_TrackZeit.total;
} else {
display =b_TrackZeit.total;
}
// Trackslider
if (trackDrag != true) regler_mc._x = (MySound.position / MySound.duration) * sliderMax;
}
// Dual digits
function checkDigits(pWert) {
return (pWert<10) ? pWert="0"+pWert : pWert;
}
// Status indication (Bar)
function sBalken(obj) {
prozent = _global.position*100/_global.dauer;
this[obj]._xscale = prozent;
prozent = parseInt(prozent)+"%";
}
// Double click
MovieClip.prototype.dClick = function(tempo) {
ASSetPropFlags(this,["clickZeit"],1);
if (this.clickZeit-(this.clickZeit=getTimer())+tempo>0) return true;
}
// Look of the Components Parameters playerlook
// (Simple/Extended Version)
if (!playerlook) gotoAndStop(3);
// Direct Choice
function setzeDirektwahl() {
for (var j=1; j <= 500; j++) {
this["dw" + j + "_btn"].nrtxt = j;
if (j > totalAudio) {
this["dw" + j + "_btn"].nr_txt.text = "--";
}
}
}
function setzeAudiowahl(pAkt) {
aktAudio = pAkt;
AudioPath = aPath[aktAudio-1];
titel = songTitel[aktAudio-1];
artist = songArtist[aktAudio-1];
MySound.stop();
playSignal = 0;
pauseSignal = 0;
wahlSignal = 1;
delete pausePos;
kugel_mc._visible = 0;
trackAnzeige = aktAudio+" / "+totalAudio;
status = "Status: stopped - press play";
setCover(aktAudio-1);
playSong();
}
// Trackslider
trackDrag = false;
sliderMax = bigdisplay_mc._width;
regler_mc.onPress = function() {
if (this._parent.MySound) {
trackDrag = true;
startDrag(this,false,0,this._y, sliderMax,this._y);
this._parent.onMouseMove = function() { updateAfterEvent() };
}
}
regler_mc.onRelease = regler_mc.onReleaseOutside = function() {
if (this._parent.MySound) {
trackDrag = false;
delete this._parent.onMouseMove;
stopDrag();
neuePosition = (this._x * (MySound.duration / 1000)) / sliderMax;
pausePos = neuePosition;
MySound.stop();
MySound.start(neuePosition, 0);
kugel_mc._visible = 1;
status = "Status: playing";
dstatus = status;
playSignal = true;
pauseSignal = false;
}
}
regler_mc.onRollOver = function() {
dstatus = status;
status = "Status: Drag Slider";
}
regler_mc.onRollOut = function() {
status = dstatus;
}
// Repeat Clip
repeat_mc._visible = 0;
// Repeat Button
repeat_btn.onRelease = function() {
playrepeat = !playrepeat;
repeat_mc._visible = playrepeat;
}
repeat_btn.onRollOver = function() {
dstatus = status;
status = "Status: repeat track";
}
repeat_btn.onRollOut = function() {
status = dstatus;
}
// Playlist Selection
// Direct Choice
function setzePlaylistwahl() {
playauswahl.playliste = "";
for (var j=1; j <= aPath.length; j++) {
playauswahl.playliste += "<a href='asfunction:playauswahl,"+j+"'>"+j+". "+songTitel[(j-1)].substr(0,200)+"</u></a><br>";
}
}
function playlistauswahl(pAkt) {
aktAudio = int(pAkt);
AudioPath = aPath[aktAudio-1];
titel = songTitel[aktAudio-1];
artist = songArtist[aktAudio-1];
MySound.stop();
playSignal = 0;
pauseSignal = 0;
wahlSignal = 1;
delete pausePos;
kugel_mc._visible = 0;
trackAnzeige = aktAudio+" / "+totalAudio;
status = "Status: stopped - press play";
setCover(aktAudio-1);
playSong();
}
Again, I truly appreciate all of your invaluable help on this.
I've made some tries and I beliebe I come up with a solution. I didn't go through the whole script you posted (time shortage), so I've just focused on the "playrepeat" & "contnuous" function. So first thing first, you DO need to declare your variables and in particular the 'playrepeat' one, add this line somewhere in your original script (perhaps right before the 'repeat_btn' function) :
var playrepeat:Boolean = false;
Now, in the 'MySound.onSoundComplete' function write down those two lines:
if (playrepeat && !continuous) {
playSong();
}
if (continuous) {
nextTrack();
}
So what happens is that if playrepeat is true and contnuous is false the audio track will be repeated but if continuous is true your script will move into the next track even if playrepeat is set to true
Non in the "nextTrack' function within the if just add this:
playSong()
And that's it really
Have a go and let me know if it works or not
I tried what you suggested but with no success. As I mentioned in my header, the "nextTrack" function may be contributing to this. I do have a nextTrack button that moves forward to the "actual next track" but can't get it to correspond with the 'continuousplay' button I have created. Also, the playrepeat function is working fine.
Here is the corresponding code (I just put the "onSoundComplete" out of the "playSong ()" function) for these buttons: