This is an Mp3 Player that I'm working on. If anyone has any suggestions Please post them. I'm writing this as a snippet purely because I havent been impressed with the quality of mp3 playng scripts lately. So feel free to rip this for your scripts. Also, please pm me with any specific errors you get and I'll revise/update the code.
This was written in Mirc 6.16 and tested back to 6.12 Update Change the play alias to mp3play so that it wont interfere with the defualt play command
This script as with all of mine is open to anyone for modifications. You dont have to ask, and I only ask that you include some sort of credit or a link back to this snippet.
;;;MP3 Player
menu channel,status {
$iif(!$dialog(mp3player),Mp3Player):dialog -md mp3player mp3player
}
dialog mp3player {
title "mp3player"
size -1 -1 142 112
option dbu
button "Play", 1, 2 96 25 12
button "Stop", 2, 30 96 25 12
button "Pause", 3, 58 96 25 12
button "< Prev", 4, 86 96 25 12
button "Next >", 5, 114 96 25 12
list 30, 2 30 136 58, size
box "Playlist:", 7, 0 22 140 70
box "Play Time", 10, 100 2 40 20
text "00:00", 11, 102 12 15 8, nowrap right
text "/", 12, 118 12 3 8
text "00:00", 13, 122 12 15 8, nowrap right
box "Status", 18, 0 2 98 20
text "No Song Is Playing", 6, 2 10 93 10, nowrap
menu "Files", 20
item "Add File", 21, 20
item "Add Dir", 22, 20
item "Remove Selected File", 28 20
item "Options", 27, 20
menu "Playlists", 23
item "Save Playlist", 24, 23
item "Load Playlist", 25, 23
item "Clear Current Playlist", 26, 23
}
on *:dialog:mp3player:init:0: {
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, saveplaylist) == 1 ) {
var %x 1
.did -r mp3player 30
while ( %x <= $lines($($+(",$scriptdir,mp3playlist.play,"))) ) {
.did -a mp3player 30 $nopath($read($($+(",$scriptdir,mp3playlist.play,")),%x))
inc %x
}
}
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, startplaying) == 1 ) {
mp3play
}
}
on *:dialog:mp3player:close:0: {
.splay stop
.unset %mp3.*
.timermp3time off
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, saveplaylist) == 1 ) {
halt
}
elseif ( $exists($($+(",$scriptdir,mp3playlist.play,"))) ) {
.remove $($+(",$scriptdir,mp3playlist.play,"))
}
}
on *:dialog:mp3player:menu:21: {
var %file $sfile($mircdir*.mp3,Add File To Playlist, Add)
if ( $right(%file,3) != mp3 ) {
.did -ra mp3player 6 Error you can only add mp3s
.timermp3status 1 3 /did -ra mp3player 6 No Song Is Playing
}
else {
.did -a mp3player 30 $nopath(%file)
.write $($+(",$scriptdir,mp3playlist.play,")) %file
}
}
on *:dialog:mp3player:menu:22: {
var %dir $sdir($mircdir,Add Dir To Playlist)
var %x 1
while ( $findfile(%dir,*.mp3,%x) != $null ) {
.did -a mp3player 30 $nopath($findfile(%dir,*.mp3,%x))
.write $($+(",$scriptdir,mp3playlist.play,")) $findfile(%dir,*.mp3,%x)
inc %x
}
}
on *:dialog:mp3player:menu:24: {
var %tempsave $sfile($mircdir*.play,Save Playlist, Save)
if ( %tempsave == $null ) { halt }
if ( $right(%tempsave,5) != .play ) {
.set %save $($+(",%tempsave,.play,"))
}
else {
.set %save $($+(",%tempsave,"))
}
if ( %save != $null ) && ( $isfile($($+(",$scriptdir,mp3playlist.play,"))) ) {
.copy -o $($+(",$scriptdir,mp3playlist.play,")) %save
}
elseif ( %save != $null ) && ( !$isfile($($+(",$scriptdir,mp3playlist.play,"))) ) {
.did -ra mp3player 6 Empty Playlists cannot be saved.
.timermp3status 1 3 /did -ra mp3player 6 No Song Is Playing
}
.unset %save
}
on *:dialog:mp3player:menu:25: {
var %mp3.playlist $($+(",$sfile($mircdir*.play,Open Playlist, Open),"))
if ( %mp3.playlist == $null ) { halt }
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, appendplaylist) != 1 ) {
if ( %mp3.playlist != $null ) && ( $isfile(%mp3.playlist) ) {
.copy -o %mp3.playlist $($+(",$scriptdir,mp3playlist.play,"))
var %x 1
.did -r mp3player 30
while ( %x <= $lines($($+(",$scriptdir,mp3playlist.play,"))) ) {
.did -a mp3player 30 $nopath($read($($+(",$scriptdir,mp3playlist.play,")),%x))
inc %x
}
}
elseif ( %mp3.playlist != $null ) && ( !$isfile(%mp3.playlist) ) {
.did -ra mp3player 6 File Not Found
.timermp3status 1 3 /did -ra mp3player 6 No Song Is Playing
}
}
else {
if ( %mp3.playlist != $null ) && ( $isfile(%mp3.playlist) ) {
.copy -a %mp3.playlist $($+(",$scriptdir,mp3playlist.play,"))
var %x 1
did -r mp3player 30
while ( %x <= $lines($($+(",$scriptdir,mp3playlist.play,"))) ) {
.did -a mp3player 30 $nopath($read($($+(",$scriptdir,mp3playlist.play,")),%x))
inc %x
}
}
elseif ( %mp3.playlist != $null ) && ( !$isfile(%mp3.playlist) ) {
.did -ra mp3player 6 File Not Found
.timermp3status 1 3 /did -ra mp3player 6 No Song Is Playing
}
}
}
on *:dialog:mp3player:menu:26: {
.did -r mp3player 30
if ( $exists($($+(",$scriptdir,mp3playlist.play,"))) ) {
.remove $($+(",$scriptdir,mp3playlist.play,"))
}
}
on *:dialog:mp3player:menu:27: {
dialog -md options options
}
on *:dialog:mp3player:menu:28: {
if ( $did(mp3player,30).sel == $null ) {
.did -ra mp3player 6 Error No Song Selected to Remove
.timermp3status 1 3 /did -ra mp3player 6 No Song Is Playing
}
else {
write $($+(-dl,$did(mp3player,30).sel),2) $($+(",$scriptdir,mp3playlist.play,"))
echo -s write $($+(-dl,$did(mp3player,30).sel),2) $($+(",$scriptdir,mp3playlist.play,"))
did -d mp3player 30 $did(mp3player,30).sel
}
if ( $timer(mp3time) != $null ) && ( $readini($($+(",$scriptdir,mp3player.ini,")), options, playnext) == 1 ) {
skipnext
}
}
on *:dialog:mp3player:dclick:30: {
if ( %mp3.paused == $did(mp3player,30).sel ) {
.timermp3time -r
.unset %mp3.paused
}
elseif ( %mp3.paused != $did(mp3player,30).sel ) {
.did -ra mp3player 6 No Song Is Playing
.did -ra mp3player 11 00:00
.did -ra mp3player 13 00:00
.timermp3time off
.unset %mp3.currenttime
}
mp3play
}
on *:dialog:mp3player:sclick:1: {
if ( %mp3.paused == $did(mp3player,30).sel ) {
.timermp3time -r
.unset %mp3.paused
}
elseif ( %mp3.paused != $did(mp3player,30).sel ) {
.timermp3time off
.unset %mp3.currenttime
}
mp3play
}
on *:dialog:mp3player:sclick:2: {
stop
}
on *:dialog:mp3player:sclick:3: {
pause
}
on *:dialog:mp3player:sclick:4: {
.did -c mp3player 30 $calc($did(mp3player,30).sel - 1)
.did -ra mp3player 6 No Song Is Playing
.did -ra mp3player 11 00:00
.did -ra mp3player 13 00:00
.unset %mp3.currenttime
.timermp3time off
mp3play
}
on *:dialog:mp3player:sclick:5: {
skipnext
}
alias mp3play {
if ( $did(mp3player,30).lines == 0 ) {
.did -ra mp3player 6 Error No Playlist
.timermp3status 1 3 /did -ra mp3player 6 No Song Is Playing
halt
}
if ( $did(mp3player,30).sel == $null ) {
.did -c mp3player 30 1
}
.splay -p $read($($+(",$scriptdir,mp3playlist.play,")),$did(mp3player,30).sel)
if ( $sound($read($($+(",$scriptdir,mp3playlist.play,")),$did(mp3player,30).sel)).title != $null ) {
.did -ra mp3player 6 *Playing* $sound($read($($+(",$scriptdir,mp3playlist.play,")),$did(mp3player,30).sel)).title
}
else {
.did -ra mp3player 6 *Playing* $nopath($read($($+(",$scriptdir,mp3playlist.play,")),$did(mp3player,30).sel))
}
.did -ra mp3player 13 $asctime($calc($sound($read($($+(",$scriptdir,mp3playlist.play,")),$did(mp3player,30).sel)).length / 1000 ),nn:ss)
.timermp3time 0 1 playtime
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, enablespam) == 1 ) && ( $readini($($+(",$scriptdir,mp3player.ini,")), options, spammsg) != $null ) && ( $active ischan ) {
msg $active $readini($($+(",$scriptdir,mp3player.ini,")), options, spammsg)
}
}
alias stop {
.splay -p stop
.did -ra mp3player 6 No Song Is Playing
.did -ra mp3player 11 00:00
.did -ra mp3player 13 00:00
.timermp3time off
.unset %mp3.currenttime
.unset %mp3.paused
}
alias pause {
.splay pause
.did -ra mp3player 6 *Paused* $sound($read($($+(",$scriptdir,mp3playlist.play,")),$did(mp3player,30).sel)).title
set %mp3.paused $did(mp3player,30).sel
.timermp3time -p
}
alias skipnext {
.did -c mp3player 30 $calc($did(mp3player,30).sel + 1)
.did -ra mp3player 6 No Song Is Playing
.did -ra mp3player 11 00:00
.did -ra mp3player 13 00:00
.unset %mp3.currenttime
.timermp3time off
mp3play
}
alias playtime {
if ( $asctime(%mp3.currenttime,nn:ss) < $asctime($calc($sound($read($($+(",$scriptdir,mp3playlist.play,")),$did(mp3player,30).sel)).length / 1000 ),nn:ss) ) {
inc %mp3.currenttime
.did -ra mp3player 11 $asctime(%mp3.currenttime,nn:ss)
}
else {
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, playnext) == 1 ) && ( $did(mp3player,30).sel < $did(mp3player,30).lines ) {
skipnext
.unset %mp3.currenttime
}
elseif ( $readini($($+(",$scriptdir,mp3player.ini,")), options, playnext) == 1 ) && ( $readini($($+(",$scriptdir,mp3player.ini,")), options, loopall) == 1 ) && ( $did(mp3player,30).sel == $did(mp3player,30).lines ) {
did -c mp3player 30 1
.unset %mp3.currenttime
mp3play
}
else {
stop
}
}
}
;;;identifiers for populating the spammsg
alias songlength {
return $asctime($calc($sound($read($($+(",$scriptdir,mp3playlist.play,")),$did(mp3player,30).sel)).length / 1000 ),nn:ss)
}
alias album {
return $sound($read($($+(",$scriptdir,mp3playlist.play,")),$did(mp3player,30).sel)).album
}
alias artist {
return $sound($read($($+(",$scriptdir,mp3playlist.play,")),$did(mp3player,30).sel)).artist
}
alias song {
return $sound($read($($+(",$scriptdir,mp3playlist.play,")),$did(mp3player,30).sel)).title
}
;;;Mp3 Player options
dialog Options {
title "Options"
size -1 -1 170 160
option dbu
button "OK", 1, 50 144 25 12, ok
button "Cancel", 2, 86 144 25 12, cancel
tab "Options", 10, 0 -2 169 143
check "Save Current Playlist on Exit", 11, 2 16 80 10, tab 10
check "Start Playing On Load", 12, 2 34 116 10, tab 10
check "Append Playlist to Current On Load", 13, 2 42 104 10, tab 10
check "Skip to next song in playlist when current song is complete", 14, 2 50 160 10, tab 10
check "Loop All Songs", 15, 2 58 154 10, tab 10
text "Note: This option does NOT write to a custom playlist.", 16, 8 26 135 8, tab 10
tab "Spam", 3
text "These options are HIGHLY discouraged as most people and ops in most Channels dislike people spamming their music in the channel.", 31, 2 14 166 18, tab 3
edit "I'm currently listening to $artist - $album - $song length: $songlength **You Must Edit This to enable spamming**", 32, 2 50 164 38, tab 3 multi autovs
text "Current song $song", 33, 6 96 53 8, tab 3
text "Album $album", 34, 6 104 53 8, tab 3
text "Length $songlength", 36, 78 104 67 8, tab 3
text "Spam Message:", 17, 4 42 39 8, tab 3
box "Message Identifiers", 37, 2 88 164 48, tab 3
text "Artist $artist", 35, 78 96 53 8, tab 3
check "Enable Spam", 39, 2 32 44 10, tab 3
text "If any of these cannot be obtained from the mp3 they will not be displayed in the message. Also do not combine these with any text or puctuation.", 38, 4 114 157 20, tab 3
}
on *:dialog:options:init:0: {
if ( $isfile($($+(",$scriptdir,mp3player.ini,"))) ) {
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, saveplaylist) == 1 ) {
.did -c options 11
}
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, startplaying) == 1 ) {
.did -c options 12
}
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, appendplaylist) == 1 ) {
.did -c options 13
}
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, playnext) == 1 ) {
.did -c options 14
}
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, loopall) == 1 ) {
.did -c options 15
}
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, enablespam) == 1 ) {
.did -c options 39
}
if ( $readini($($+(",$scriptdir,mp3player.ini,")), options, spammsg) != $null ) {
.did -ra options 32 $readini($($+(",$scriptdir,mp3player.ini,")), n, options, spammsg)
}
}
}
on *:dialog:options:sclick:1: {
.writeini $($+(",$scriptdir,mp3player.ini,")) Options saveplaylist $did(options,11).state
.writeini $($+(",$scriptdir,mp3player.ini,")) Options startplaying $did(options,12).state
.writeini $($+(",$scriptdir,mp3player.ini,")) Options appendplaylist $did(options,13).state
.writeini $($+(",$scriptdir,mp3player.ini,")) Options playnext $did(options,14).state
.writeini $($+(",$scriptdir,mp3player.ini,")) Options loopall $did(options,15).state
.writeini $($+(",$scriptdir,mp3player.ini,")) Options enablespam $did(options,39).state
if ( $did(options,32).edited == $true ) {
var %x 1
while ( %x <= $did(options,32).lines ) {
var %z 1
while ( %z <= $numtok($did(options,32,%x).text,32) ) {
if ( !%spammsg ) {
.set %spammsg $gettok($did(options,32,%x).text,%z,32)
}
else {
.set %spammsg %spammsg $gettok($did(options,32,%x).text,%z,32)
}
inc %z
}
inc %x
}
.writeini $($+(",$scriptdir,mp3player.ini,")) Options spammsg %spammsg
.unset %spammsg
}
}
on *:dialog:options:sclick:12: {
if ( $did(options,12).state == 1 ) {
if ( $did(options,11).state == 0 ) {
.did -c options 11
}
}
}
;;;end of options
I fixed it to be:
on *:dialog:mp3player:sclick:3: {
pause
}
alias pause {
.splay pause
.did -ra mp3player 6 - Paused - $sound($read($($+(\",$scriptdir,mp3playlist.play,\")),$did(mp3player,30).sel)).title
.set %mp3.paused $did(mp3player,30).sel
.timermp3time -p
}
and...:
on *:dialog:mp3player:sclick:1: {
if ( %mp3.paused == $did(mp3player,30).sel ) {
.splay resume
.timermp3time -r
.did -ar mp3player 6 - Playing - $sound($read($($+(\",$scriptdir,mp3playlist.play,\")),$did(mp3player,30).sel)).title
}
if ( %mp3.paused != $did(mp3player,30).sel ) {
.timermp3time off
.unset %mp3.currenttime
mp3play
}
}
Doing this, when it\'s paused and you click \'Play\', it will actually resume and not restart the song...
Two things I\'d like seen done to this.
A) Make a shuffle function. I knowz its possible, this arent not mah first mp3 to have.
B) This\'ll take some HARD work...but make it like a iPod, so you can check eMails and shtuff...like that one guy\'s halo2 stat grabber, maybe? >_> I fink that\'s hard work there, but so is making an mp3, and ya should work on it in yer spare time
C) Make it teach me to count.
Yeah, I\'ve actually made a much better mp3 player since this, however, it needs images and such, but it needs images, and such... I just havent uploaded it as an addon because it needs some minor rewrites to make it use the images from the script directory instead of the main directory. If anyone is interested in doing the rewrites, I should have it somewhere still.... I think I posted a link to it as \'ymp3\' or something in the forums. Anyone is free to do the rewrites, and add whilefix.dll to the while loops that add the files. And post it, with credits.