
![]() |
Apr 10 2006, 05:24 PM
Post
#1
|
|
|
The Funky Stuff ![]() ![]() ![]() ![]() Group: Publishing Betazoids Posts: 2,307 Joined: 21-February 05 From: Zurich, Switzerland Member No.: 3,327 |
okay, yeh.. you ALWAYS wanted a pause button on your mp3 player? The time has come, here you go:
1 - First of all create a pause Button using the wingdings font and convert it to a button, don't forget to give it an unique instance name like "btn_pause" 2 - Go to your root timeline, select your actions frame and put this after the play button... (or where-ever you want) small explanation included CODE 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 } 3. then we change our play Button script slightly so we can check if pause is true CODE 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]); } }; 4. DONE! You don't need to use the pause variable on every situation, this was now done, because most of the people switched the random play off. Which would cause that the player wouldn't know anymore where to start playing.. |
|
|
Apr 11 2006, 02:16 PM
Post
#2
|
|
|
Young Padawan ![]() Group: Members Posts: 25 Joined: 23-August 05 Member No.: 10,204 |
okay, yeh.. you ALWAYS wanted a pause button on your mp3 player? The time has come, here you go: 1 - First of all create a pause Button using the wingdings font and convert it to a button, don't forget to give it an unique instance name like "btn_pause" 2 - Go to your root timeline, select your actions frame and put this after the play button... (or where-ever you want) small explanation included CODE 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 } 3. then we change our play Button script slightly so we can check if pause is true CODE 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]); } }; 4. DONE! You don't need to use the pause variable on every situation, this was now done, because most of the people switched the random play off. Which would cause that the player wouldn't know anymore where to start playing.. Nice tut dude:) |
|
|
Apr 13 2006, 03:00 PM
Post
#3
|
|
|
Young Padawan ![]() Group: Members Posts: 6 Joined: 11-April 06 Member No.: 17,708 |
3. then we change our play Button script slightly so we can check if pause is true
CODE 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]); } }; after implementing this bit of code I found that the song name and band don't show up after hitting stop and then play again. so i grabbed the bit from the forward button to get it working again.... CODE this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
|
|
|
Apr 13 2006, 03:12 PM
Post
#4
|
|
|
The Funky Stuff ![]() ![]() ![]() ![]() Group: Publishing Betazoids Posts: 2,307 Joined: 21-February 05 From: Zurich, Switzerland Member No.: 3,327 |
nice catch!
Thx! |
|
|
Apr 13 2006, 03:24 PM
Post
#5
|
|
|
Young Padawan ![]() Group: Members Posts: 6 Joined: 11-April 06 Member No.: 17,708 |
|
|
|
Apr 13 2006, 03:45 PM
Post
#6
|
|
|
The Funky Stuff ![]() ![]() ![]() ![]() Group: Publishing Betazoids Posts: 2,307 Joined: 21-February 05 From: Zurich, Switzerland Member No.: 3,327 |
strange, as soon as you press stop the counter goes back to 00, so that shouldn't be a problem of the pause button
|
|
|
Apr 21 2006, 03:15 PM
Post
#7
|
|
|
Young Padawan ![]() Group: Members Posts: 2 Joined: 21-April 06 Member No.: 17,996 |
Funkysoul,
Sent you an email regarding running two versions of this MP3 player within one swf, without conflicts. Please respond, and if you think the answer might be helpful to others post the info here as well. Thanks |
|
|
May 9 2006, 09:08 AM
Post
#8
|
|
|
Young Padawan ![]() Group: Members Posts: 43 Joined: 9-November 05 Member No.: 13,015 |
Funkysoul i got a bit of prob!
i implented as said Pause Button CODE 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 } then i changed paly button CODE 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"; this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr]); } }; There r two conditions tht can happen! Condition 1 If i play the song and press stop...the song stops...If i press play again the song will play again frm the start Condition 2 Suppose my song is playing and suddenly i press Pause...the song will pause itself after some time i press play again...the song will continue frm where it was paused. Here comes the problem Now wen i want to listen to the song frm the start i press stop button...the song will stop to listen to it again i press Play...instead of playing frm the start it plays frm where i stopped......It is like if u press pause once the stop button will start to act like pause button!! Here is the complete code i use CODE 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; } } _root.createEmptyMovieClip("sound_mc",1); _global.song_nr = (0); } function timer(sound_obj) { time=sound_obj.position/1000; min=Math.floor(time/60); min=(min<10)?"0"+min:min; sec=Math.floor(time%60); sec=(sec<10)?"0"+sec:sec; timeDisplay_txt.text=min+":"+sec; } MovieClip.prototype.songStarter = function (file, name) { if (this.sound_obj){ this.sound_obj.stop(); delete this.sound_obj; } this.sound_obj = new Sound(this) this.sound_obj.loadSound(file,true) this.onEnterFrame = function () { if(this.sound_obj.position>0) { delete this.onEnterFrame; this._parent.display_txt.text=name; timeInterval = setInterval(timer, 1000, this.sound_obj); } else { this._parent.display_txt.text="loading..." } } this.sound_obj.onSoundComplete = function () { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; (song_nr==songfile.length-1)? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr]); } this._parent.volume1.dragger.onPress = function() { startDrag(this, true, 0, this._y, this._parent.volBG._width, this._y); this.onEnterFrame = function() { var p = (this._x/this._parent.volBG._width)*100; this._parent._parent.sound_mc.sound_obj.setVolume(p); }; } this._parent.volume1.dragger.onRelease = function() { delete this.onEnterFrame; stopDrag(); }; this._parent.volume1.dragger.onReleaseOutside = function() { stopDrag(); }; } 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"; this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr]); } }; btn_stop.onRelease = function() { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; this._parent.sound_mc.sound_obj.stop(); } btn_next.onRelease = function () { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; (song_nr==songfile.length-1)? _global.song_nr=0 : _global.song_nr++; _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr]); } btn_prev.onRelease = function () { clearInterval(timeInterval); this._parent.timeDisplay_txt.text="00:00"; (song_nr==0)? _global.song_nr=songfile.length-1 : _global.song_nr--; _root.sound_mc.songStarter(songfile[song_nr],songname[song_nr]) } 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("playlist.xml"); This post has been edited by Amrik: May 9 2006, 09:15 AM |
|
|
May 9 2006, 11:15 AM
Post
#9
|
|
|
The Funky Stuff ![]() ![]() ![]() ![]() Group: Publishing Betazoids Posts: 2,307 Joined: 21-February 05 From: Zurich, Switzerland Member No.: 3,327 |
put on the stop button the variable
CODE pause = false;
|
|
|
May 10 2006, 12:05 AM
Post
#10
|
|
|
Young Padawan ![]() Group: Members Posts: 43 Joined: 9-November 05 Member No.: 13,015 |
Thx buddy....worked perfectly alrite!!!
|
|
|
May 10 2006, 07:32 PM
Post
#11
|
|
|
Young Padawan ![]() Group: Members Posts: 1 Joined: 9-May 06 Member No.: 18,549 |
Is there a way to make the player buffer up a certain amount and play once it has loaded a bit of the song? Also, Could the stop button be more like the pause button, but instead of it saving the position it just sets the position back to the begining?
This post has been edited by DriveGira: May 10 2006, 08:28 PM |
|
|
May 11 2006, 01:25 AM
Post
#12
|
|
|
The Funky Stuff ![]() ![]() ![]() ![]() Group: Publishing Betazoids Posts: 2,307 Joined: 21-February 05 From: Zurich, Switzerland Member No.: 3,327 |
put this line on top of your script, replace xx with the number of seconds you want to buffer
CODE _soundbuftime = xx;
|
|
|
Jun 3 2006, 03:02 AM
Post
#13
|
|
|
Young Padawan ![]() Group: Members Posts: 66 Joined: 3-June 06 From: Los Angeles Member No.: 19,288 |
funky funk soul,
you probably figured this out but when try out the player, it doesn't show the song name when it's scrolling. For certain ones, it will show but when it loads up another song, it'll scroll across and show just the line that splits the song name and band. Can you or anyone else help me with that problem. Also, is it possible to add a scroll bar to it? It would be a great tutorial to have adding a scroll bar. |
|
|
Jun 3 2006, 07:22 AM
Post
#14
|
|
|
The Funky Stuff ![]() ![]() ![]() ![]() Group: Publishing Betazoids Posts: 2,307 Joined: 21-February 05 From: Zurich, Switzerland Member No.: 3,327 |
if you are using ID3 tags to show up the artist & title, it will only show up when the song is completely loaded. So you need to go back to the XML version of the title or you use a FMS2 (which is $$$$) and you can use the ID3 tags...
Scrollbar? scrollbar for what? scrub the track or what? |
|
|
Jun 3 2006, 12:40 PM
Post
#15
|
|
|
Young Padawan ![]() Group: Members Posts: 66 Joined: 3-June 06 From: Los Angeles Member No.: 19,288 |
you know after reading the last line I wrote, it made no sense to me. lol What I meant was adding a scroll bar to the playlist so that if I have tooooooooo many tracks, I can scroll through them... know what I mean, if not, then I'm a baboon at explaining things
|
|
|
Jun 3 2006, 12:59 PM
Post
#16
|
|
|
The Funky Stuff ![]() ![]() ![]() ![]() Group: Publishing Betazoids Posts: 2,307 Joined: 21-February 05 From: Zurich, Switzerland Member No.: 3,327 |
what about creating a dropdown box using the components from Flash8 ?
in that way you save some space. other then that there are a bunch of tutorials out there on how to make scrollable movieclips.. |
|
|
Jul 22 2006, 02:04 AM
Post
#17
|
|
|
Young Padawan ![]() Group: Members Posts: 1 Joined: 22-July 06 Member No.: 20,563 |
I fond a bug: if you export the SWF file in anything other Flash Version 6 the scrolling text just keeps going. the code thats supost to bring it back to the start point dosen't seem to be working: it's the line if (_root.title_txt._x < (-100-_root.title_txt.width))
If I take out -_root.title_txt.width and just had -100 it works. I been trying to figure it out for past several week and I've been pulling my hair out! CODE this.onEnterFrame = function() {
_root.title_txt._x -= 1; if (_root.title_txt._x < (-100-_root.title_txt.width)) { _root.title_txt._x = 219; } } |
|
|
Jul 22 2006, 02:49 AM
Post
#18
|
|
|
Young Padawan ![]() Group: Members Posts: 40 Joined: 1-July 06 Member No.: 20,120 |
sweet. people always ask for these!
|
|
|
Jul 22 2006, 06:34 AM
Post
#19
|
|
|
The Funky Stuff ![]() ![]() ![]() ![]() Group: Publishing Betazoids Posts: 2,307 Joined: 21-February 05 From: Zurich, Switzerland Member No.: 3,327 |
CODE this.onEnterFrame = function() { _root.title_txt._x -= 1; if (_root.title_txt._x < (-100-_root.title_txt._width)) { _root.title_txt._x = 219; } } this should work |
|
|
Jul 31 2006, 02:03 PM
Post
#20
|
|
|
Young Padawan ![]() Group: Members Posts: 1 Joined: 31-July 06 Member No.: 20,789 |
Hey funkysoul,
Awesome tutorial, man. Question: Is it possible to make the textdisplayer transparent so one can only see the text and not the textfield? Another question: Can you explain how to swap between the play and pause button during playback? This is what I like to achieve: When one hits play, the song will play. During playback, the pause button is being displayed instead of the playbutton at that very same place. In addittion: If stop is hit, the playbutton appears again (since there's no sound to pause) Thx in advance, Tijmen |
|
|
![]() |
|
Lo-Fi Version | Time is now: 21st November 2009 - 11:32 AM |