ok here it goes a simple but good mp3 player. i got the ideas from another mp3 player. cheers
dialog mplayer {
title "Mp3 Player"
size -1 -1 340 186
option dbu
list 1, 7 9 146 123, size hsbar vsbar
button "<--", 2, 4 149 14 12
button "Play", 3, 22 149 28 12
button "Pause", 4, 53 149 28 12
button "Resume", 5, 83 149 28 12
button "Stop", 6, 113 149 28 12
button "-->", 7, 144 149 14 12
text "Now Playing:", 8, 157 12 35 8, center
edit "", 9, 200 12 119 8, center read
box "Volume", 10, 201 41 79 50
button "+", 11, 213 61 14 12
button "-", 12, 247 61 14 12
button "Add Directory", 13, 172 150 38 12
button "Add File", 14, 214 150 37 12
button "Delete File", 15, 254 150 37 12
button "Clear", 16, 295 150 37 12
box "Mp3 Announce", 17, 201 95 79 50
radio "On", 18, 213 108 50 10
radio "Off", 19, 213 123 50 10
}
alias up {
set %currentvolume $vol(mp3)
inc %currentvolume 5000
if ( %currentvolume > 65535 ) { set %currentvolume 65535 }
vol -p %currentvolume
}
alias down {
set %currentvolume $vol(mp3)
dec %currentvolume 5000
if ( %currentvolume < 0 ) { set %currentvolume 0 }
vol -p %currentvolume
}
alias read.playlist {
%ln = 0
set %lines $lines(playlist.txt)
:loop
if (%ln == %lines) { goto end }
inc %ln
did -az mplayer 1 $nopath($read(playlist.txt, %ln))
goto loop
:end {
}
}
on 1:dialog:mplayer:sclick:18: set %annou ON
on 1:dialog:mplayer:sclick:18: set %annou OFF
on 1:dialog:mplayer:sclick:11: up
on 1:dialog:mplayer:sclick:12: down
on 1:dialog:mplayer:sclick:6: splay -p stop | unset %mp3.fname
on 1:dialog:mplayer:sclick:4: pause
on 1:dialog:mplayer:sclick:7: next
on 1:dialog:mplayer:sclick:2: prev
on 1:dialog:mplayer:sclick:14: set %m.playlist $dir="select an mp3:" [ %mp3dir $+ *.mp3 ] | if (%m.playlist == $null) halt | else { write playlist.txt %m.playlist | did -az mplayer 1 $nopath(%m.playlist) | unset %m.playlist }
on 1:dialog:mplayer:sclick:13: add.dir
on 1:dialog:mplayer:sclick:3: mp32 $read(playlist.txt, %a.line)
on 1:dialog:mplayer:sclick:15: write -dl $+ %a.line playlist.txt | did -dz mplayer 1 %a.line
on 1:dialog:mplayer:sclick:1: set %a.line $did(mplayer,1).sel
on 1:dialog:mplayer:sclick:16: write -c playlist.txt | did -rz mplayer 1
on 1:dialog:mplayer:init:*:{
read.playlist
did -a mplayer 9 $remove($nopath(%mp3.fname),.mp3))
}
alias add.dir {
set %p.dir $sdir="select a dir:" C:\ | if (%p.dir == $null) halt | else { goto start }
:start
set %x 0
:loop
inc %x 1
if ($findfile(%p.dir,*.mp3,%x) == $null) { goto end }
else {
write playlist.txt $findfile(%p.dir,*.mp3,%x)
did -az mplayer 1 $findfile(%p.dir,*.mp3,%x)
goto loop
}
:end
halt
}
alias mp32 {
set %mp3.fname $1-
if (%mp3.fname != $null) {
splay -p %mp3.fname
set %length $replace($round($calc($file(%mp3.fname).size / 126 / $gettok($mp3(%mp3.fname).bitrate,1,3)),0),mins,m,secs,s)
if (%annou == on) { //ame is listening to: $nopath(%mp3.fname) }
dialog -x mplayer mplayer
dialog -m mplayer mplayer
}
}
alias pause {
if ($did(mplayer,6).state == 0) { splay resume }
else { splay pause }
}
alias next {
set %total $lines(playlist.txt)
%active = 0
if ($lines(playlist.txt) = 1) { mp32 $read(playlist.txt,1) | goto end }
if ($lines(playlist.txt) = 0) { var %x = $input(There Are No Songs. Load A Play List,o,Warning) | goto end }
else { goto loop }
:loop
inc %active 1
if ($read(playlist.txt, %active) = %mp3.fname) { inc %active 1 | checkstat next | mp32 $read(playlist.txt, %active) | unset %active | goto end }
if (%active > %total) { $input(There Are No More Songs. Use Previous or Load Another PlayList,o,Warning) | goto end }
else { goto loop }
:end
}
alias prev {
set %total $lines(playlist.txt)
%active = 0
if ($lines(playlist.txt) = 1) { mp32 $read(playlist.txt,1) | goto end }
if ($lines(playlist.txt) = 0) { var %x = $input(There Are No More Songs. Use Previous or Load Another PlayList,o,Warning) | goto end }
else { goto loop }
:loop
inc %active 1
if ($read(playlist.txt, %active) = %mp3.fname) { dec %active 1 | checkstat prev | mp32 $read(playlist.txt, %active) | unset %active | goto end }
if (%active > %total) { $input(There Are No More Songs. Use Next button,o,warning) | goto end }
else { goto loop }
:end
}
alias checkstat {
if ($1 = next) {
if (%active > %total) { set %active 1 }
}
if ($1 = prev) {
if (%active = 0) { set %active $lines(playlist.txt) }
}
}
menu * {
-
mp3: /dialog -m mplayer mplayer
}