Funkysoul's (great) MP3 Player & external swf addon...
Started by
plon
, Jul 24 2006 10:24 AM
6 replies to this topic
#1
Posted 24 July 2006 - 10:24 AM
Hello !
Let's introduce my work :
I'm in a french independant power-pop band called Bubblies, we're about to release our new album on an USB key with MP3 songs, bonus and lot of things...
I'm working on an mp3 player (included on the USB key) based on Funkysoul tut.
I want to create two levels for navigation between songs : next & prev button on the player and one button for each songs (each button is different so I create them one by one - only 12)
I would like to implement, for each song, a graphical animation (external swf could be easier for future evolutions....).
For now, the external anim works when i Click on the direct button but is not linked with played song.
I would like to use AS and same xml file (playlist.xml) to load anim on click (next & prev) and each button... and when a new song begin, change it too...
I know the method will be similar to the sound part.... But i'm a action script noob and need some help.
I burnt some part of my brain making the songs playing in the chosen order after choosing one with individual song button...
Could someone please give me some direction to begin or some link ?
Here is th AS part :
------------------------------------------------------------------------------------------------------------------------------------------------------
stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songfile = [];
for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
trace(songname[i]+" "+songfile[i]);
}
}
_root.createEmptyMovieClip("sound_mc", 1);
_root.sound_mc.sound_obj = new Sound();
_global.song_nr = 0;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
MovieClip.prototype.songStarter = function(file, name) {
this.sound_obj.loadSound(file, true);
this.onEnterFrame = function() {
if (this.sound_obj.position>0) {
delete this.onEnterFrame;
this._parent.display_txt.text = name;
} else {
this._parent.display_txt.text = "press play ...";
}
};
this.sound_obj.onSoundComplete = function() {
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
};
btn_play.onRelease = function() {
if (pause == true){ // no comment....
this._parent.sound_mc.sound_obj.start(posiP) // start sound from the previously saved position
}
else {
clearInterval(timeInterval);
_root.timeDisplay_txt.text = "00:00/00:00";
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
}
};
btn_stop.onRelease = function() {
this._parent.sound_mc.sound_obj.stop();
pause = false;
};
btn_fw.onRelease = function() {
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
pause = false;
};
btn_rev.onRelease = function() {
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
pause = false;
};
btn_pause.onRelease = function() { //pause button function
this._parent.sound_mc.sound_obj.stop(); //stop the current sound
posiP = _root.sound_mc.sound_obj.position / 1000; // save the current position in a new variable and divide by 1000 (ms -> sec)
pause = true;//set the variable pause to true
}
playlist.load("things/playlist.xml");
// Individual song buttons
btn_glitter.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[0], songname[0]);
_global.song_nr=0
};
btn_lamouche.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[1], songname[1]);
_global.song_nr=1
};
btn_space.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[2], songname[2]);
_global.song_nr=2};
btn_stone.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[3], songname[3]);
_global.song_nr=3};
btn_thehead.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[4], songname[4]);
_global.song_nr=4};
btn_icescream.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[5], songname[5]);
_global.song_nr=5};
btn_labelvie.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[6], songname[6]);
_global.song_nr=6};
btn_amiabird.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[7], songname[7]);
_global.song_nr=7};
btn_spirale.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[8], songname[8]);
_global.song_nr=8};
btn_miracle.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[9], songname[9]);
_global.song_nr=9};
btn_sucre.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[10], songname[10]);
_global.song_nr=10};
btn_memories.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[11], songname[11]);
_global.song_nr=11};
------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks !!
Plon.
ps : sorry for my approximative english....
Let's introduce my work :
I'm in a french independant power-pop band called Bubblies, we're about to release our new album on an USB key with MP3 songs, bonus and lot of things...
I'm working on an mp3 player (included on the USB key) based on Funkysoul tut.
I want to create two levels for navigation between songs : next & prev button on the player and one button for each songs (each button is different so I create them one by one - only 12)
I would like to implement, for each song, a graphical animation (external swf could be easier for future evolutions....).
For now, the external anim works when i Click on the direct button but is not linked with played song.
I would like to use AS and same xml file (playlist.xml) to load anim on click (next & prev) and each button... and when a new song begin, change it too...
I know the method will be similar to the sound part.... But i'm a action script noob and need some help.
I burnt some part of my brain making the songs playing in the chosen order after choosing one with individual song button...
Could someone please give me some direction to begin or some link ?
Here is th AS part :
------------------------------------------------------------------------------------------------------------------------------------------------------
stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songfile = [];
for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
trace(songname[i]+" "+songfile[i]);
}
}
_root.createEmptyMovieClip("sound_mc", 1);
_root.sound_mc.sound_obj = new Sound();
_global.song_nr = 0;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
MovieClip.prototype.songStarter = function(file, name) {
this.sound_obj.loadSound(file, true);
this.onEnterFrame = function() {
if (this.sound_obj.position>0) {
delete this.onEnterFrame;
this._parent.display_txt.text = name;
} else {
this._parent.display_txt.text = "press play ...";
}
};
this.sound_obj.onSoundComplete = function() {
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
};
};
btn_play.onRelease = function() {
if (pause == true){ // no comment....
this._parent.sound_mc.sound_obj.start(posiP) // start sound from the previously saved position
}
else {
clearInterval(timeInterval);
_root.timeDisplay_txt.text = "00:00/00:00";
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
}
};
btn_stop.onRelease = function() {
this._parent.sound_mc.sound_obj.stop();
pause = false;
};
btn_fw.onRelease = function() {
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
pause = false;
};
btn_rev.onRelease = function() {
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
pause = false;
};
btn_pause.onRelease = function() { //pause button function
this._parent.sound_mc.sound_obj.stop(); //stop the current sound
posiP = _root.sound_mc.sound_obj.position / 1000; // save the current position in a new variable and divide by 1000 (ms -> sec)
pause = true;//set the variable pause to true
}
playlist.load("things/playlist.xml");
// Individual song buttons
btn_glitter.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[0], songname[0]);
_global.song_nr=0
};
btn_lamouche.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[1], songname[1]);
_global.song_nr=1
};
btn_space.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[2], songname[2]);
_global.song_nr=2};
btn_stone.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[3], songname[3]);
_global.song_nr=3};
btn_thehead.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[4], songname[4]);
_global.song_nr=4};
btn_icescream.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[5], songname[5]);
_global.song_nr=5};
btn_labelvie.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[6], songname[6]);
_global.song_nr=6};
btn_amiabird.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[7], songname[7]);
_global.song_nr=7};
btn_spirale.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[8], songname[8]);
_global.song_nr=8};
btn_miracle.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[9], songname[9]);
_global.song_nr=9};
btn_sucre.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[10], songname[10]);
_global.song_nr=10};
btn_memories.onRelease = function() {
this._parent.sound_mc.songStarter(songfile[11], songname[11]);
_global.song_nr=11};
------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks !!
Plon.
ps : sorry for my approximative english....
#2
Posted 24 July 2006 - 11:10 AM
what about something like this:
put this into the main timeline, frame 1 right at the beginning of the actionscript (line1)
use this code for every button changing the "anim1.swf" to an Array Object like you did for the soundfiles.
eg. here the complete code, you just need to change the XML to have an extra field for the animation
That should work..
Cheers
Funkysoul
put this into the main timeline, frame 1 right at the beginning of the actionscript (line1)
_root.createEmptyMovieClip("animHolder",getNextHighestDepth()); _root.animHolder._x = 0;//x position _root.animHolder._y = 0;//y position
use this code for every button changing the "anim1.swf" to an Array Object like you did for the soundfiles.
loadMovie("anim1.swf", animHolder);
eg. here the complete code, you just need to change the XML to have an extra field for the animation
_root.createEmptyMovieClip("animHolder",getNextHighestDepth()); _root.animHolder._x = 0;//x position _root.animHolder._y = 0;//y position stop(); playlist = new XML(); playlist.ignoreWhite = true; playlist.onLoad = function(success) { if (success) { _global.songname = []; _global.songfile = []; _global.songanim = []; for (var i = 0; i<playlist.firstChild.childNodes.length; i++) { _global.songname[i] = playlist.firstChild.childNodes[i].attributes.name; _global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file; _global.songanim[i] = playlist.firstChild.childNodes[i].attributes.animation; trace(songname[i]+" "+songfile[i]); } } _root.createEmptyMovieClip("sound_mc", 1); _root.sound_mc.sound_obj = new Sound(); _global.song_nr = 0; _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]); }; MovieClip.prototype.songStarter = function(file, name) { this.sound_obj.loadSound(file, true); this.onEnterFrame = function() { if (this.sound_obj.position>0) { delete this.onEnterFrame; this._parent.display_txt.text = name; } else { this._parent.display_txt.text = "press play ..."; } }; this.sound_obj.onSoundComplete = function() { (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]); }; }; btn_play.onRelease = function() { if (pause == true){ // no comment.... this._parent.sound_mc.sound_obj.start(posiP) // start sound from the previously saved position } else { clearInterval(timeInterval); _root.timeDisplay_txt.text = "00:00/00:00"; this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]); } }; btn_stop.onRelease = function() { this._parent.sound_mc.sound_obj.stop(); pause = false; }; btn_fw.onRelease = function() { (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]); pause = false; }; btn_rev.onRelease = function() { (song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--; _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]); pause = false; }; btn_pause.onRelease = function() { //pause button function this._parent.sound_mc.sound_obj.stop(); //stop the current sound posiP = _root.sound_mc.sound_obj.position / 1000; // save the current position in a new variable and divide by 1000 (ms -> sec) pause = true;//set the variable pause to true } playlist.load("things/playlist.xml"); // Individual song buttons btn_glitter.onRelease = function() { loadMovie(songanim[0],animHolder); this._parent.sound_mc.songStarter(songfile[0], songname[0]); _global.song_nr=0 }; btn_lamouche.onRelease = function() { loadMovie(songanim[1],animHolder); this._parent.sound_mc.songStarter(songfile[1], songname[1]); _global.song_nr=1 }; btn_space.onRelease = function() { loadMovie(songanim[2],animHolder); this._parent.sound_mc.songStarter(songfile[2], songname[2]); _global.song_nr=2}; btn_stone.onRelease = function() { this._parent.sound_mc.songStarter(songfile[3], songname[3]); _global.song_nr=3}; btn_thehead.onRelease = function() { this._parent.sound_mc.songStarter(songfile[4], songname[4]); _global.song_nr=4}; btn_icescream.onRelease = function() { this._parent.sound_mc.songStarter(songfile[5], songname[5]); _global.song_nr=5}; btn_labelvie.onRelease = function() { this._parent.sound_mc.songStarter(songfile[6], songname[6]); _global.song_nr=6}; btn_amiabird.onRelease = function() { this._parent.sound_mc.songStarter(songfile[7], songname[7]); _global.song_nr=7}; btn_spirale.onRelease = function() { this._parent.sound_mc.songStarter(songfile[8], songname[8]); _global.song_nr=8}; btn_miracle.onRelease = function() { this._parent.sound_mc.songStarter(songfile[9], songname[9]); _global.song_nr=9}; btn_sucre.onRelease = function() { this._parent.sound_mc.songStarter(songfile[10], songname[10]); _global.song_nr=10}; btn_memories.onRelease = function() { this._parent.sound_mc.songStarter(songfile[11], songname[11]); _global.song_nr=11};
That should work..
Cheers
Funkysoul
Edited by funkysoul, 24 July 2006 - 11:11 AM.
#3
Posted 24 July 2006 - 11:29 AM
Great !! I'm going to try it !!!
Thanks a lot....
Give you feed back when done !
Plon.
Thanks a lot....
Give you feed back when done !
Plon.
#4
Posted 24 July 2006 - 12:22 PM
On clicking on individual button, it works fine after a little correction at line :
Must be :
I still have a little problem :
It works only when clicking on individual button, but when i choose the songs with prev & next nutton, nothing ... (neither on first song played...)
I think i begin to understand ....
Let's try ...
(thanks again)
Plon.
_global.songanim[i] = playlist.firstChild.childNodes[i].attributes.animation;
Must be :
_global.songanim[i] = playlist.firstChild.childNodes[i].attributes.anim;
I still have a little problem :
It works only when clicking on individual button, but when i choose the songs with prev & next nutton, nothing ... (neither on first song played...)
I think i begin to understand ....
Let's try ...
(thanks again)
Plon.
#5
Posted 24 July 2006 - 12:34 PM
you need to put the action for the loadmovie also inside the rev and fw button, always incrementing the id /decrementing incase of rev
#6
Posted 24 July 2006 - 12:52 PM
you need to put the action for the loadmovie also inside the rev and fw button, always incrementing the id /decrementing incase of rev
I don't need to increment/decrement the id if I use for fw and prev button :
_root.animHolder.loadMovie(songanim[song_nr],animHolder)It seems to work...
#7
Posted 24 July 2006 - 01:02 PM
Done !!!
Everything is working fine !
External swf are loaded when :
- Main scene is loaded (first song plays, related swf too)
- a song end, the next one begin to play and the related anim too
- clicking on independant songs button (one for each song)
- clicking next, prev buttons....
Great !
here is the final action script :
Merci for your quick answers !!!!
Plon.
Everything is working fine !
External swf are loaded when :
- Main scene is loaded (first song plays, related swf too)
- a song end, the next one begin to play and the related anim too
- clicking on independant songs button (one for each song)
- clicking next, prev buttons....
Great !
here is the final action script :
_root.createEmptyMovieClip("animHolder",getNextHighestDepth()); _root.animHolder._x = 100;//x position _root.animHolder._y = 0;//y position stop(); playlist = new XML(); playlist.ignoreWhite = true; playlist.onLoad = function(success) { if (success) { _global.songname = []; _global.songfile = []; _global.songanim = []; for (var i = 0; i<playlist.firstChild.childNodes.length; i++) { _global.songname[i] = playlist.firstChild.childNodes[i].attributes.name; _global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file; _global.songanim[i] = playlist.firstChild.childNodes[i].attributes.anim; trace(songname[i]+" "+songfile[i]); } } _root.createEmptyMovieClip("sound_mc", 1); _root.sound_mc.sound_obj = new Sound(); _global.song_nr = 0; _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]); _root.animHolder.loadMovie(songanim[song_nr],animHolder) }; MovieClip.prototype.songStarter = function(file, name) { this.sound_obj.loadSound(file, true); this.onEnterFrame = function() { if (this.sound_obj.position>0) { delete this.onEnterFrame; this._parent.display_txt.text = name; } else { this._parent.display_txt.text = "press play ..."; } }; this.sound_obj.onSoundComplete = function() { (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]); _root.animHolder.loadMovie(songanim[song_nr],animHolder) }; }; btn_play.onRelease = function() { if (pause == true){ // no comment.... this._parent.sound_mc.sound_obj.start(posiP) // start sound from the previously saved position } else { clearInterval(timeInterval); _root.timeDisplay_txt.text = "00:00/00:00"; this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]); } }; btn_stop.onRelease = function() { this._parent.sound_mc.sound_obj.stop(); pause = false; }; btn_fw.onRelease = function() { (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]); // Modif anim fw _root.animHolder.loadMovie(songanim[song_nr],animHolder); pause = false; }; btn_rev.onRelease = function() { (song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--; _root.sound_mc.songStarter(songfile[song_nr], songname[song_nr]); // Modif anim rev _root.animHolder.loadMovie(songanim[song_nr],animHolder) pause = false; }; btn_pause.onRelease = function() { //pause button function this._parent.sound_mc.sound_obj.stop(); //stop the current sound posiP = _root.sound_mc.sound_obj.position / 1000; // save the current position in a new variable and divide by 1000 (ms -> sec) pause = true;//set the variable pause to true } playlist.load("things/playlist.xml"); // Individual song buttons btn_glitter.onRelease = function() { loadMovie(songanim[0],animHolder); this._parent.sound_mc.songStarter(songfile[0], songname[0]); _global.song_nr=0}; btn_lamouche.onRelease = function() { loadMovie(songanim[1],animHolder); this._parent.sound_mc.songStarter(songfile[1], songname[1]); _global.song_nr=1}; btn_space.onRelease = function() { loadMovie(songanim[2],animHolder); this._parent.sound_mc.songStarter(songfile[2], songname[2]); _global.song_nr=2}; btn_stone.onRelease = function() { loadMovie(songanim[3],animHolder); this._parent.sound_mc.songStarter(songfile[3], songname[3]); _global.song_nr=3}; btn_thehead.onRelease = function() { loadMovie(songanim[4],animHolder); this._parent.sound_mc.songStarter(songfile[4], songname[4]); _global.song_nr=4}; btn_icescream.onRelease = function() { loadMovie(songanim[5],animHolder); this._parent.sound_mc.songStarter(songfile[5], songname[5]); _global.song_nr=5}; btn_labelvie.onRelease = function() { loadMovie(songanim[6],animHolder); this._parent.sound_mc.songStarter(songfile[6], songname[6]); _global.song_nr=6}; btn_amiabird.onRelease = function() { loadMovie(songanim[7],animHolder); this._parent.sound_mc.songStarter(songfile[7], songname[7]); _global.song_nr=7}; btn_spirale.onRelease = function() { loadMovie(songanim[8],animHolder); this._parent.sound_mc.songStarter(songfile[8], songname[8]); _global.song_nr=8}; btn_miracle.onRelease = function() { loadMovie(songanim[9],animHolder); this._parent.sound_mc.songStarter(songfile[9], songname[9]); _global.song_nr=9}; btn_sucre.onRelease = function() { loadMovie(songanim[10],animHolder); this._parent.sound_mc.songStarter(songfile[10], songname[10]); _global.song_nr=10}; btn_memories.onRelease = function() { loadMovie(songanim[11],animHolder); this._parent.sound_mc.songStarter(songfile[11], songname[11]); _global.song_nr=11};
Merci for your quick answers !!!!
Plon.
Edited by plon, 24 July 2006 - 01:06 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users