MP3 Player Script Problems/Questions - 20/09/03 07:49 AM
I have started to learn to script and in my learning I have decided to make an MP3 player, now I have a few questions regarding the script and was wondering if anyone would mind helping me out.
First heres the dialog code:
( fulls cript below )
1- Now, if you are looking at it, you will see the scroll bar under the top edit box, I want to make this a progress bar without using any dll's, and also use the < and > scroll buttons as seek like seen in many mp3 scripts.
2- Another thing is How do I retreive the total mb's from a dir?
3- Multiple sclick events going to one alias? How? I tried $iif(did(id)) and if ($did(id1)) { then } if ($did(id2)) { then } but nothing seems to work.
Also any concerns, comments, or improvments will be greatly appreciated, also please provide, Why? and How its done, remember I am new to this. Thanks in advance.
Heres the complete code:
First heres the dialog code:
Code:
dialog ntoxamp { title "nT0xAmP" size -1 -1 174 180 option dbu edit "", 1, 2 11 170 10, read center box "", 2, 1 7 172 24 scroll "", 3, 3 21 167 8, horizontal bottom button "<<", 4, 3 45 13 12, flat button "|<", 5, 17 45 13 12, flat button "[>", 6, 31 45 13 12, flat button "[ ]", 7, 45 45 13 12, flat button "| |", 8, 59 45 13 12, flat button ">|", 9, 73 45 13 12, flat button ">>", 10, 87 45 13 12, flat edit "", 11, 3 32 26 10, read center box "", 12, 1 27 172 17 edit "", 13, 107 32 64 10, read center edit "", 14, 29 32 26 10, read center edit "", 15, 55 32 26 10, read center edit "", 16, 81 32 26 10, read center box "", 17, 1 40 172 19 box "", 18, 1 66 172 68 list 19, 3 71 168 50, sort size button "Add Mp³", 20, 4 122 26 10, flat button "Remove Mp³", 21, 32 122 35 10, flat button "Generate Playlst Text File", 22, 102 122 68 10, flat box "", 23, 1 130 172 25 combo 24, 3 142 144 37, size drop button "+", 25, 149 142 10 10, flat button "-", 26, 160 142 10 10, flat text "[ Mp³ Directories ]", 27, 4 134 166 8, center button "x", 28, 163 1 9 8, flat button "_", 29, 153 1 9 8, flat text "«~'|| ntoXic8dAmP ||'~» (v)1.0.0b", 30, 1 2 151 8, center check "Shuffle", 31, 145 45 25 12, flat push check "Repeat", 32, 119 45 25 12, flat push box "", 33, 85 151 88 16 box "", 34, 1 151 85 16 check "Announce to Channel", 35, 12 156 66 10 check "Disable Announce on Away", 36, 91 156 76 10 box "", 37, 1 163 172 16 button "« « ~ finished ~ » »", 38, 3 168 168 9, flat ok box "", 39, 1 55 172 15 text "« vol »", 40, 3 60 17 8 button "+", 41, 21 60 9 8, flat button "-", 42, 31 60 9 8, flat button "X", 43, 41 60 9 8, flat edit "", 44, 51 59 22 10, read center edit "", 45, 73 59 97 10, read center }
( fulls cript below )
1- Now, if you are looking at it, you will see the scroll bar under the top edit box, I want to make this a progress bar without using any dll's, and also use the < and > scroll buttons as seek like seen in many mp3 scripts.
2- Another thing is How do I retreive the total mb's from a dir?
3- Multiple sclick events going to one alias? How? I tried $iif(did(id)) and if ($did(id1)) { then } if ($did(id2)) { then } but nothing seems to work.
Also any concerns, comments, or improvments will be greatly appreciated, also please provide, Why? and How its done, remember I am new to this. Thanks in advance.
Heres the complete code:
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;# Script: «~- nToXIc8d AmP -~» ||| Version: v.1.0.1 #; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;# Coding: sheyz (sheyz@sheyz.net) #; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias mp3 { dialog -am ntoxamp ntoxamp } alias load.settings { vol -v %vol .timer1 1 1 did -a ntoxamp 44 %vol.pos .timer3 1 2 list } alias exit { unset %mp3 %mp3.song %nub %file %mp3.stat.* } alias list { if (%mp3.dir == $null) { set %mp3.dir $dir "Where are your Mp3's?" } did -r ntoxamp 19 var %r 1 while ( %r <= $findfile(%mp3.dir,*.mp3,0) ) { did -a ntoxamp 19 $nopath($findfile(%mp3.dir,*.mp3,%r)) inc %r } unset %r did -a ntoxamp 45 $findfile(%mp3.dir,*.mp3,0,999) mp3's,totaling: mb did -ra ntoxamp 24 %mp3.dir } alias mp3.vol { if ($did(41)) { if (%vol >= 65535) { halt } else { inc %vol $calc(65535/100*10) vol -v %vol set %vol.pos $calc(%vol / 6553.5) $+ 0 $+ % if (%vol.pos == 100%) { did -ra ntoxamp 44 MAX } else { did -ra ntoxamp 44 %vol.pos } halt } } if ($did(42)) { if (%vol <= 0) { halt } else { dec %vol $calc(65535/100*10) vol -v %vol set %vol.pos $calc(%vol/6553.5) $+ 0 $+ % if (%vol.pos == 00%) { did -ra ntoxamp 44 MIN } else { did -ra ntoxamp 44 %vol.pos } halt } } if ($did(43)) { if (%mp3.mute == 0) { set %mute 1 set %un.mute %vol vol -v 0 did -ra ntoxamp 44 Mute halt } else { set %mute 0 vol -v %un.mute did -ra ntoxamp 44 $calc(%vol / 6553.5) $+ 0 $+ % unset %un.mute halt } } } alias mp3.stop { splay stop } alias mp3.say { if ($did(35).state) { ame is playing: %mp3.song $mp3.stats } elseif ($did(35).state) { echo -a On but off } else { did -b ntoxamp 36 } } alias mp3.play { mp3.stats did -ra ntoxamp 1 %mp3.song did -ra ntoxamp 11 %mp3.stats.kbps did -ra ntoxamp 16 %mp3.stats.len did -ra ntoxamp 14 %mp3.stats.mode did -ra ntoxamp 15 %mp3.stats.size did -r ntoxamp 13 splay -pq %mp3.dir $+ \ $+ %mp3 $mp3.say unset %say* } alias mp3.stats { set %mp3.stats.size $round($calc($lof(%file) / 1048576),2) $+ mb set %mp3.stats.len $remove($duration($calc(($mp3(%file).length - $inmp3.pos) / 1000)),rs,ins,ecs) set %mp3.stats.kbps $mp3($iif(file,%file,$inmp3.fname)).bitrate set %mp3.stats.mode $lower($replace($remove($mp3($iif(%file,%file,$inmp3.fname)).mode,joint,$chr(32),channel),single,mono)) return 10(11size:15 $+ %mp3.size $+ 10) (11length:15 $+ %mp3.len $+ 10) (11kbps:15 $+ %mp3.kbps $+ 10) (11mode:15 $+ %mp3.mode $+ 10) } dialog ntoxamp { title "nT0xAmP" size -1 -1 174 180 option dbu edit "", 1, 2 11 170 10, read center box "", 2, 1 7 172 24 scroll "", 3, 3 21 167 8, horizontal bottom button "<<", 4, 3 45 13 12, flat button "|<", 5, 17 45 13 12, flat button "[>", 6, 31 45 13 12, flat button "[ ]", 7, 45 45 13 12, flat button "| |", 8, 59 45 13 12, flat button ">|", 9, 73 45 13 12, flat button ">>", 10, 87 45 13 12, flat edit "", 11, 3 32 26 10, read center box "", 12, 1 27 172 17 edit "", 13, 107 32 64 10, read center edit "", 14, 29 32 26 10, read center edit "", 15, 55 32 26 10, read center edit "", 16, 81 32 26 10, read center box "", 17, 1 40 172 19 box "", 18, 1 66 172 68 list 19, 3 71 168 50, sort size button "Add Mp³", 20, 4 122 26 10, flat button "Remove Mp³", 21, 32 122 35 10, flat button "Generate Playlst Text File", 22, 102 122 68 10, flat box "", 23, 1 130 172 25 combo 24, 3 142 144 37, size drop button "+", 25, 149 142 10 10, flat button "-", 26, 160 142 10 10, flat text "[ Mp³ Directories ]", 27, 4 134 166 8, center button "x", 28, 163 1 9 8, flat button "_", 29, 153 1 9 8, flat text "«~'|| ntoXic8dAmP ||'~» (v)1.0.0b", 30, 1 2 151 8, center check "Shuffle", 31, 145 45 25 12, flat push check "Repeat", 32, 119 45 25 12, flat push box "", 33, 85 151 88 16 box "", 34, 1 151 85 16 check "Announce to Channel", 35, 12 156 66 10 check "Disable Announce on Away", 36, 91 156 76 10 box "", 37, 1 163 172 16 button "« « ~ finished ~ » »", 38, 3 168 168 9, flat ok box "", 39, 1 55 172 15 text "« vol »", 40, 3 60 17 8 button "+", 41, 21 60 9 8, flat button "-", 42, 31 60 9 8, flat button "X", 43, 41 60 9 8, flat edit "", 44, 51 59 22 10, read center edit "", 45, 73 59 97 10, read center } on *:dialog:ntoxamp:init:0 { load.settings } on *:dialog:ntoxamp:dclick:19: { set %file %mp3.dir $+ $did(19).seltext set %mp3 $did(19).seltext set %mp3.song $replace($remove(%mp3,.mp3),_,$chr(32)) if ($insong == $true) { splay -c stop } mp3.play } on *:dialog:ntoxamp:sclick:*: { if ($devent == 4) { mp3.prev } if ($devent == 5) { mp3.rev } if ($devent == 6) { set %file %mp3.dir $+ $did(19).seltext set %mp3 $did(19).seltext set %mp3.song $replace($remove(%mp3,.mp3),_,$chr(32)) if ($insong == $true) { splay -c stop } mp3.play } if ($devent == 7) { mp3.stop } if ($devent == 8) { mp3.pause } if ($devent == 9) { mp3.forw } if ($devent == 10) { mp3.next } if ($devent == 25) { set %mp3.dir $sdir(c:\,"Where is your Mp3 directory located?") | list } if ($devent == 41) { mp3.vol } if ($devent == 42) { mp3.vol } if ($devent == 43) { mp3.vol } if ($devent == 35) { mp3.say } if ($devent == 36) { return $did(36,1,0) } if ($devent == 28) { exit } if ($devent == 29) { dialog -ie ntoxamp ntoxamp } }