[code]/*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ MP3 Player | Chars: 40974 | Lines: 1208 @
@ Credits: Neptune: irc.PurpleSurge.com @
@ Daveoh: irc.Quakenet.org @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*/
#fkeys on
;function key aliases
alias f10 { $run.mp3 }
alias f11 { if ($inmp3) { if ($inmp3.pause) splay resume | else splay pause } }
alias f12 { mp3broadcast }
#fkeys end
;on load events
on *:load: {
set %dialog mp3
echo -a 0,0/11,0/0,11/12,11/11,12/2,12/12,2/1,2/2,1/0,1 Thank you for downloading this MP3 Player.
echo -a 0,0/11,0/0,11/12,11/11,12/2,12/12,2/1,2/2,1/0,1 To open, type /mp3 or right-click anywhere and select MP3.
}
;menu
menu * {
.MP3 Player: { $run.mp3 }
}
;alias to open dialog
alias mp3 { $run.mp3 }
;mp3 player dialog
dialog mp3 {
title "MP3 Player"
size -1 -1 387 375
option pixels %notheme
list 1, 5 5 185 290, hsbar vsbar size
edit "", 2, 203 25 170 20, read autohs
button "<<", 5, 200 110 50 20, flat
button "||", 6, 230 135 50 20, flat
button "|>", 7, 300 135 50 20, flat
button ">>", 8, 330 110 50 20, flat
button "Directory", 9, 203 226 80 25, flat
scroll "", 13, 203 70 170 16, horizontal range 0 100
box "Now Playing", 10, 193 9 190 41
box "Position", 11, 193 55 190 36
button "[]", 22, 265 110 50 20, flat
box "Control", 4, 193 95 190 65
button "Remove All", 26, 293 226 80 25, flat
button "Add File", 27, 203 264 80 25, flat
button "Delete File", 28, 293 264 80 25, flat
box "MP3's", 29, 193 211 190 83
scroll "", 12, 203 183 170 16, horizontal range 0 65535
box "Volume", 14, 193 166 190 40
edit "", 3, 5 325 185 20, read
edit "", 34, 5 350 185 20, read
button "Center", 20, 205 325 170 20, flat
button "Hide", 19, 205 350 170 20, flat
button "MP3 Information of what's playing", 18, 4 300 185 20, flat
button "Broadcast Now!", 23, 205 300 170 20, flat
menu "File", 15
item "Options", 16, 15
item "Broadcasting", 17, 15
item "break", 30, 15
item "Exit", 21, 15
menu "Tools", 30
menu "Export to Text", 33, 30
item "Write to MP3 List", 36, 33
item "View MP3 List", 35, 33
menu "Function Keys", 45, 30
item "On", 46, 45
item "Off", 47, 45
item "Status", 48, 45
item "break", 51, 30
item "Advertise", 49, 30
item "break", 50, 30
item "ID3 Tag Editor", 44, 30
menu "View", 37
item "Mini Mode", 39, 37
menu "Style", 40, 37
item "Themed", 41, 40
item "Retro", 42, 40
menu "Help", 24
item "Topics", 31, 24
item "break", 32, 24
item "About", 25, 24
}
;advertising
on *:dialog:mp3:menu:49: {
msg $active 0,0/11,0/0,11/12,11/11,12/2,12/12,2/1,2/2,1/1,1/0,1 I am using the MP3 Player, found @ http://www.hawkee.com/snippet/4267/
}
;enable function keys
on *:dialog:mp3:menu:46: {
enable #fkeys
echo -a 0,0/11,0/0,11/12,11/11,12/2,12/12,2/1,2/2,1/1,1/0,1 Function Keys are now on.
}
;disable function keys
on *:dialog:mp3:menu:47: {
disable #fkeys
echo -a 0,0/11,0/0,11/12,11/11,12/2,12/12,2/1,2/2,1/1,1/0,1 Function Keys are now off.
}
;view status
on *:dialog:mp3:menu:48: {
if ($group(#fkeys) == on) {
echo -a 0,0/11,0/0,11/12,11/11,12/2,12/12,2/1,2/2,1/1,1/0,1 Function Keys are currently on.
}
elseif ($group(#fkeys) == off) {
echo -a 0,0/11,0/0,11/12,11/11,12/2,12/12,2/1,2/2,1/1,1/0,1 Function Keys are currently off.
}
}
;open id3 tag editor
on *:dialog:mp3:menu:44: { $id3.open }
;open mp3 info dialog
on *:dialog:mp3:sclick:18: { dialog -md mp3.info mp3.info }
;mp3 info dialog
dialog mp3.info {
title "MP3 Information"
size -1 -1 360 219
option pixels notheme
edit "", 1, 0 0 360 20, read
edit "", 2, 0 20 360 20, read
edit "", 3, 0 40 360 20, read
edit "", 4, 0 60 360 20, read
button "Close", 6, 0 200 360 18, flat
edit "", 5, 0 80 360 20, read
edit "", 8, 0 100 360 20, read
edit "", 9, 0 140 360 20, read
edit "", 10, 0 120 360 20, read
edit "", 7, 1 160 360 20, read
edit "", 11, 1 180 360 20, read
}
;mp3 info initialization
on *:dialog:mp3.info:init:0: {
var %title2 = $iif($sound($read(playlist.txt,%songnum)).title,$v1,$regsubex($gettok($nopath($inmp3.fname),-1,45),/(.mp3)$/,))
var %artist2 = $iif($sound($read(playlist.txt,$did(1).sel)).artist,$v1,$gettok($nopath($inmp3.fname),-2,45))
var %len2 = $remove($duration($calc($inmp3.length /1000),3),00:)
var %bit2 = $sound($read(playlist.txt,%songnum)).bitrate
var %genre2 = $iif($sound($insong.fname).genre, $sound($insong.fname).genre, Unknown genre)
var %album2 = $iif($sound($insong.fname).album, $sound($insong.fname).album, Unknown album)
var %size2 = $bytes($file($insong.fname).size).suf
var %year2 = $iif($sound($insong.fname).year, $sound($insong.fname).year, Unknown year)
var %comment2 = $iif($sound($insong.fname).comment, $sound($insong.fname).comment, No comment)
did -a $dname 1 Title: %title2
did -a $dname 2 Artist: %artist2
did -a $dname 3 Length: %len2
did -a $dname 4 Played: $readini(playcount.ini,plays,$replace($inmp3.fname,$chr(32),_))) time(s)
did -a $dname 5 Album: %album2
did -a $dname 8 Genre: %genre2
did -a $dname 9 Year: %year2
did -a $dname 10 Comment: %comment2
did -a $dname 7 Size: %size2
did -a $dname 11 Bitrate: %bit2 $+ kbps
}
;mp3 info close
on *:dialog:mp3.info:sclick:6: { dialog -x $dname }
;broadcast now button
on *:dialog:mp3:sclick:23: { mp3broadcast }
;dialog themes
on *:dialog:mp3:menu:41: {
unset %notheme
dialog -x $dname
dialog -md mp3 mp3
}
on *:dialog:mp3:menu:42: {
set %notheme notheme
dialog -x $dname
dialog -md mp3 mp3
}
;mp3 dialog initialisation
on *:dialog:mp3:init:0:{
var %a = 1, %b = playlist.txt
while ( %a <= $lines(%b) ) {
did -a $dname 1 $left($nopath($read(%b,%a)),-4)
inc %a
}
did -a $dname 34 Played: $readini(playcount.ini,plays,$replace($inmp3.fname,$chr(32),_)))
did -z $dname 1
did -a $dname 3 Total MP3's: $did(1).lines
did -c $dname 12 $vol(master)
if ( $readini(playcount.ini,plays,$replace($read(playlist.txt,%songnum),$chr(32),_)) ) did -o $dname 34 1 Played: $v1
if ( $inmp3 ) {
did -c $dname 1 %songnum
did -o $dname 2 1 $left($nopath($inmp3.fname),-4)
did -z $dname 13 0 10000
did -c $dname 13 $calc(($inmp3.pos / $inmp3.length)*10000)
.timerpos.update -r
if ( %mp3.sm != none && $width($left($nopath($inmp3.fname),-4),Arial,10) > 150 ) .timerscrolltitle 0 1 scrolltitle
}
}
;dialog close
on *:dialog:mp3:close:0: {
.timerpos.update -p
.timerscrolltitle off
set %dialog mp3
}
;dialog buttons
;click in list
on *:dialog:mp3:dclick:1: {
set %songnum $did(1).sel
mp3play $read(playlist.txt,%songnum)
}
on *:dialog:mp3:sclick:1: {
did -ra $dname 34 Played: $iif($readini(playcount.ini,plays,$replace($read(playlist.txt,$did(1).sel),$chr(32),_)),$v1,0)
}
;position scrollbar
on *:dialog:mp3:scroll:13: {
if ( !$inmp3 ) halt
if ( !%mp3tseek ) { .timerpos.update -p | set %mp3tseek $true }
.timermp3tseek -m 1 500 splay seek $int($calc(($did(13).sel /10000) * $inmp3.length)) $chr(124) unset %mp3tseek $chr(124) .timerpos.update -r
}
;back button
on *:dialog:mp3:sclick:5: {
if ( %rplay ) did -c $dname 1 $r(1,$did($dname,1).lines)
elseif ( $did($dname,1).sel == 1 ) halt
did -c $dname 1 $calc($v1 - 1)
set %songnum $did($dname,1).sel
mp3play $read(playlist.txt,%songnum)
}
;stop button
on *:dialog:mp3:sclick:22: { mp3stop }
;forward button
on *:dialog:mp3:sclick:8: {
if ( %rplay ) did -c $dname 1 $r(1,$did($dname,1).lines)
else did -c $dname 1 $calc($did($dname,1).sel + 1)
set %songnum $did($dname,1).sel
mp3play $read(playlist.txt,%songnum)
}
;pause button
on *:dialog:mp3:sclick:6: {
if ( $inmp3 ) {
set %pauseb on
if ( !$inmp3.pause ) splay pause
else splay resume
set %pauseb off
}
}
;play button
on *:dialog:mp3:sclick:7: {
if ($inmp3.pause) {
splay resume
}
else {
set %songnum $did(1).sel
mp3play $read(playlist.txt,%songnum)
}
}
;volume scrollbar
on *:dialog:mp3:scroll:12: {
vol -v $did($did).sel
}
;directory button
on *:dialog:mp3:sclick:9: { mp3choosedir }
;remove all button
on *:dialog:mp3:sclick:26: { mp3remall }
;add file button
on *:dialog:mp3:sclick:27: { mp3addfile }
;delete file button
on *:dialog:mp3:sclick:28: { mp3remfile }
;close button
on *:dialog:mp3:sclick:19: {
.timerpos.update -p
.timerscrolltitle off
set %dialog mp3
dialog -x $dname
}
;menu item exit
on *:dialog:mp3:menu:21: {
.timerpos.update -p
set %dialog mp3
dialog -x $dname
}
;center button
on *:dialog:mp3:sclick:20: { dialog -r mp3 }
;mp3end
on *:MP3END: {
.timerscrolltitle off
unset %mp3.scroll*
if ( %cplay ) {
if ( %songnum < $lines(playlist.txt) ) {
inc %songnum
if ( $dialog(mp3) ) did -c mp3 1 %songnum
mp3play $read(playlist.txt,%songnum)
halt
}
unset %songnum
unset %cplay
}
elseif ( %rplay ) {
if ( $lines(playlist.txt) !> 1 ) { unset %rplay | goto off }
:picksong
var %song = $read(playlist.txt)
if ( $readn == %songnum ) goto picksong
set %songnum $readn
if ( $dialog(mp3) ) did -c mp3 1 $readn
mp3play %song
halt
}
elseif ( %repeat ) {
mp3play $read(playlist.txt,%songnum)
halt
}
if ( $dialog(mp3) ) {
did -z mp3 13 0 0
did -r mp3 2
if ( $did(mp3,1).sel == %songnum ) did -ra mp3 34 $calc($did(mp3,34)+1)
}
:off
timerpos off
unset %songnum
}
;aliases
;id3 open alias
alias -l id3.open {
var %input = $input(In order to edit ID3 tags you must stop using any files. Do you wish to continue?,y,Attention!)
%input
if (%input == $true) {
splay stop
dialog -md id3 id3
}
elseif (%input == $false) {
dialog $iif($dialog(mp3),-v,-md) mp3 mp3
}
}
;run.mp3 alias
alias -l run.mp3 {
if (!%dialog) {
set %dialog mp3
dialog $iif($dialog(mp3),-v,-md) mp3 mp3
}
else {
if (%dialog == mp3) {
dialog $iif($dialog(mp3),-v,-md) mp3 mp3
}
if (%dialog == mini) {
dialog $iif($dialog(mini),-v,-md) mini mini
}
}
}
;directory alias
alias -l mp3choosedir {
if ( $sdir(.,Choose mp3 directory) ) {
did -r mp3 1
write -c playlist.txt
var %x = 1, %d = $v1
while ( $findfile(%d,*.mp3,%x) ) {
write playlist.txt $v1
did -a mp3 1 $left($nopath($v1),-4)
inc %x
}
did -ra mp3 3 Total MP3's: $calc(%x -1)
}
}
;add file alias
alias -l mp3addfile {
if ( $sfile(*.mp3,Choose an mp3 file to add) ) {
write playlist.txt $v1
did -a mp3 1 $left($nopath($v1),-4)
did -ra mp3 3 $did(mp3,1).lines
}
}
;remove file alias
alias -l mp3remfile {
if (!$did(1).sel) {
noop $input(You did not specify a file to delete.,uwo,Error!)
}
else {
if ( $exists(playlist.txt) && $did(mp3,1).sel ) {
var %l = $did(mp3,1).lines, %s = $v1
if ( %l == 1 ) .remove playlist.txt
else write -dl playlist.txt %s
did -d $dname 1 %s
if ( %l ) {
if ( %s <= %l ) did -c $dname 1 %s
else did -c $dname 1 %l
}
did -ra mp3 3 %l
}
}
}
;remove all alias
alias -l mp3remall {
.remove playlist.txt
did -r mp3 1
did -ra mp3 3 0
if ( $inmp3 ) mp3stop
}
;play alias
alias -l mp3play {
splay $$1-
.timerscrolltitle off
unset %mp3.scroll*
writeini playcount.ini plays $replace($1-,$chr(32),_) $calc($readini(playcount.ini,plays,$replace($1-,$chr(32),_))+1)
if ( %broadcasting ) mp3broadcast
if ( $dialog(mp3) ) {
did -c mp3 13 0
did -o mp3 2 1 $left($nopath($1-),-4)
did -z mp3 13 0 10000
did -ra mp3 34 Played: $readini(playcount.ini,plays,$replace($1-,$chr(32),_))
timerpos on
if ( %mp3.sm != none && $width($left($nopath($1-),-4),Arial,10) > 120 ) .timerscrolltitle 0 1 scrolltitle
}
if ( $dialog(mini) ) {
did -ra mini 3 $nopath($read(playlist.txt,%songnum))
}
}
;stop alias
alias -l mp3stop {
if ( $inmp3 ) {
splay stop
did -r mp3 2
timerpos off
did -z mp3 13 0 0
unset %cplay
unset %songnum
unset %rplay
.timerscrolltitle off
unset %mp3.scroll*
}
}
;timerpos alias
alias -l timerpos {
if ( $1 == on ) .timerpos.update 0 1 did -c mp3 13 $!calc(( $!insong.pos / $!insong.length )*10000)
elseif ( $1 == off ) .timerpos.update off
}
;backlength alias
alias -l backlength {
if ( $inmp3 ) { return $+(-,$gmt($calc($calc($inmp3.length / 1000) - $calc($inmp3.pos / 1000)),nn:ss))
}
}
;scroll title alias
alias -l scrolltitle {
var %t = $did(mp3,1,%songnum) $iif(!%mp3.sm, $chr(160) $chr(160) $chr(160) $chr(160) $chr(160) $chr(160) $chr(160) $did(mp3,1,%songnum)), %l = $calc($len($did(mp3,1,%songnum))+7)
if ( %mp3.scroll == $null ) {
set %mp3.scroll.dir inc
set %mp3.scroll 0
set %mp3.scroll.len $len(%t)
did -o mp3 2 1 $mid(%t,1,%mp3.scroll.len)
}
elseif ( %mp3.sm == two && %mp3.scroll !> 1 ) {
set %mp3.scroll.dir inc
set %mp3.scroll 2
did -o mp3 2 1 $mid(%t,2,%mp3.scroll.len)
}
else {
if ( !%mp3.sm ) && (%mp3.scroll > %l) set %mp3.scroll 1
if ( !%mp3.sm ) did -o mp3 2 1 $mid(%t,%mp3.scroll,%mp3.scroll.len)
%mp3.scroll.dir %mp3.scroll 2
if ( %mp3.sm == two ) {
if ( $width($mid(%t,%mp3.scroll,%mp3.scroll.len),Arial,10) > 120 ) did -o mp3 2 1 $mid(%t,%mp3.scroll,%mp3.scroll.len)
else {
set %mp3.scroll.dir dec
dec %mp3.scroll 2
did -o mp3 2 1 $mid(%t,$iif(%mp3.scroll,$v1,1),%mp3.scroll.len)
}
}
}
}
;broadcasting alias
alias -l mp3broadcast {
if ( !$inmp3 ) { echo -a 0,0/11,0/0,11/12,11/11,12/2,12/12,2/1,2/2,1/1,1/0,1 MP3 Player Broadcast: Cannot broadcast while no song is playing | return }
if ( !%broadcastformat || !%broadcastchannels ) { echo -a 0,0/11,0/0,11/12,11/11,12/2,12/12,2/1,2/2,1/1,1/0,1 MP3 Player Broadcast: Broadcast options not set up correctly | return }
var %title = $iif($sound($read(playlist.txt,%songnum)).title,$v1,$regsubex($gettok($nopath($inmp3.fname),-1,45),/(.mp3)$/,))
%artist = $iif($sound($read(playlist.txt,%songnum)).artist,$v1,$gettok($nopath($inmp3.fname),-2,45))
%len = $remove($duration($calc($inmp3.length /1000),3),00:)
%rem = $remove($duration($calc(($inmp3.length -$inmp3.pos) /1000),3),00:)
%bit = $sound($read(playlist.txt,%songnum)).bitrate
%genre = $iif($sound($insong.fname).genre, $sound($insong.fname).genre, Unknown genre)
%album = $iif($sound($insong.fname).album, $sound($insong.fname).album, Unknown album)
%size = $bytes($file($insong.fname).size).suf
%mode = $mp3($insong.fname).mode
%frequency = $+($round($calc($mp3($insong.fname).sample / 1000),1)),kHz)
%pos = $iif($int($calc(($inmp3.pos /1000)/60)) > 10,$int($calc(($inmp3.pos /1000)/60)), 0 $+ $int($calc(($inmp3.pos /1000)/60)) ) $+ : $+ $iif($round($calc(($inmp3.pos /1000) - $int($calc(($inmp3.pos /1000)/60))*60),0) > 10, $round($calc(($inmp3.pos /1000) - $int($calc(($inmp3.pos /1000)/60))*60),0), 0 $+ $round($calc(($inmp3.pos /1000) - $int($calc(($inmp3.pos /1000)/60))*60),0))
%year = $iif($sound($insong.fname).year, $sound($insong.fname).year, Unknown year)
%comment = $iif($sound($insong.fname).comment, $sound($insong.fname).comment, No comment)
%msg = $replace(%broadcastformat,&title,%title,&year,%year,&mode,%mode,&genre,%genre,&artist,%artist,&len,%len,&album,%album,&comment,%comment,&size,%size,&rem,%rem,&pos,%pos,&frequency,%frequency,&bitrate,%bit,&playcount,$readini(playcount.ini,plays,$replace($inmp3.fname,$chr(32),_)))
if ( %broadcastchannels == all ) $iif(%bc.msg == describe,ame,amsg) %msg
if ( %broadcastchannels == active ) $iif(%bc.msg,%bc.msg,msg) $active %msg
else {
tokenize 44 %broadcastchannels
var %i = 1
while $(,$ $+ %i) {
msg $v1 %msg
inc %i
}
var %c = $addtok(%c,$iif(#* !iswm $v1,$chr(35) $+ $v2,$v2),44)
inc %i
}
}
;options dialog
on *:dialog:mp3:menu:16: { if (!$dialog(mp3.options)) dialog -md mp3.options mp3.options
else dialog -v mp3.options
}
dialog mp3.options {
title "Configuration Options"
size -1 -1 295 110
option pixels %notheme
box "Play options", 1, 5 0 290 35
radio "Normal", 2, 15 15 60 17
radio "Continuous", 3, 80 15 80 17
radio "Random", 4, 160 15 60 17
button "Close", 5, 5 80 285 25
box "Scrolling Method", 10, 5 40 285 35
radio "None", 11, 15 55 60 17
radio "Two-way", 12, 80 55 80 17
radio "Forwards only", 13, 160 55 85 17
radio "Repeat", 6, 225 15 66 17
}