This is a work in progress, still some bugs still in here but works. Code is still a bit messy i haven't had time to go through and clean it up. still have a lot to add to it. it does have an auto update feature so any updates will be automatically downloaded (if it's enabled) . This Script has some features that other mp3 players have such as song position bar, volume bar and display options.
How To use:
load script -> right click in a window -> click on "MP3 Player"
to add a single song: click "add song" and choose the .mp3 file to add
to add an entire directory: click "add Directory" and choose the directory you want to add
VERSION UPDATED
Version: 1.3
What's new in Version 1.3:
More display options
More auto update settings
New display for settings
Small things added such as time remaining and a mute button
Ability to edit song info eg. artist, title, album.
Support of WhileFix.dll to keep mIRC from freezing when going through big while loops (OPTIONAL) (link for download: http://www.mircscripts.org/comments.php?cid=2617)
Ability to sort songs by artist or title
Option to change way songs are displayed in the list
And other little features/bugs updated
Features in the older Version:
Volume Controls
Song position
Ability to edit a songs display name
Different playing methods (eg. continuous, repeat, random)
Different display options
Automatic display of what's playing
Auto update
A "Whats new" message when update is downloaded
More display options
And lots more...
Updates to come:
This will be edited later on.
Bug fixes
Some small but useful edits
And lots more...
As said above, there's still a lot more to fix and add so expect updates. Any comments or ideas on what to add is always helpful. I hope you all enjoy it.
To keep up-to-date on this project or to give ideas you can join my channel: /server -m irc.swiftirc.net:6667 -j #MP3
; ############################################
; ## MP3 Player ##
; ## Made By: ##
; ## Anthony1293 ##
; ## ##
; ## Version: 1.3 ##
; ############################################
;<!-- PLEASE DO NOT EDIT THE FIRST 7 LINES AS THEY ARE IMPORTANT TO THE AUTO UPDATE FEATURE -->
on *:LOAD: {
writeini mplayer.ini defaults updatemsg $false
writeini mplayer.ini defaults autoupdate $true
writeini mplayer.ini version current $pversion
echo 3 -a Thank you for using this MP3 Player made by: Anthony1293
echo -a -
echo 3 -a To start right click in a window and click on "MP3 Player" or type /mplayer
checkupdate
}
on *:START: {
if ($readini(mplayer.ini,defaults,autoupdate) == $true || $readini(mplayer.ini,mp3,check.on.start) == $true) { checkupdate }
}
menu * {
MP3 Player:/mplayer
}
dialog aboutmp3 {
title About MP3 Player
size -1 -1 200 100
option dbu
text "", 1, 45 10 100 10, center
text "", 2, 45 20 100 10, center
text "", 3, 35 40 130 40, center
button "Close", 4, 90 85 20 10, cancel
}
dialog mp3help {
title MP3 Player Help
size -1 -1 200 150
option dbu
text "Auto Updates:", 1, 45 10 100 10, center
text "", 2, 25 20 150 15, center
text "", 3, 25 40 150 15, center
text "How to use:", 4, 45 70 100 10, center
text "", 5, 25 80 150 15, center
text "", 6, 25 95 150 20, center
}
on *:dialog:mp3help:init:0: {
did -a $dname 2 To turn auto updates on/off go to: Options -> Updates -> Auto Updates
did -a $dname 3 To manually update your version of the script go to: Options -> Updates -> Check for Updates
did -a $dname 5
did -a $dname 6
}
dialog mplayer {
title MP3 Player - Made by: Anthony1293
size -1 -1 310 250
option dbu
check "Mute", 1, 260 168 20 10
button "Edit Display Info", 2, 90 214 45 10, disable
button "Refresh List", 3, 135 214 35 10
text "Title:", 4, 200 30 20 10
text "Artist:", 5, 200 40 22 10
text "", 6, 220 40 72 9
text "", 36, 220 30 72 10
menu "File", 37
item "Exit", 40, 37, cancel
menu "Options", 47
item "Settings", 81
menu "Updates", 52, 47
item "Check for Updates", 48, 52
item "Auto update", 53, 52
menu "Help", 49
item "Help", 50
item "About", 51
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
list 56, 20 30 150 180, hsbar vsbar size
button "<<", 58, 200 110 25 10, flat
button "||", 59, 215 130 25 10, flat
button "|>", 60, 246 130 25 10, flat
button ">>", 61, 260 110 25 10, flat
button "Add Directory", 62, 200 205 37 10, flat
scroll "", 63, 203 65 80 16, horizontal range 0 100
box "Song Info", 64, 193 20 100 30
box "Position", 65, 193 55 100 30
button "[]", 66, 230 110 25 10, flat
box "Song Controls", 67, 193 90 100 65
button "Remove All", 68, 250 205 37 10, flat
button "Add Song", 69, 200 220 37 10, flat
button "Delete Song", 70, 250 220 37 10, flat
box "MP3's", 71, 193 195 100 40
scroll "", 72, 203 170 80 16, horizontal range 0 65535
box "Volume Controls", 73, 193 160 100 30
text "", 74, 20 215 70 10, read
text "", 75, 20 230 70 10, read
text "", 76, 203 63 20 10
text "", 77, 268 63 20 10
button "MP3 Information of what's playing", 78, 4 300 185 20, flat
button "Show what i’m listening to", 79, 90 229 80 10, flat disable
text "Playing method:", 82, 20 21 40 8
check "Continuous", 83, 65 20 35 10
check "Random", 84, 105 20 30 10
check "Repeat", 85, 138 20 35 10
text "Sort By:", 86, 38 8 20 10
radio "Artist", 87, 65 7 22 10, group
radio "Title", 88, 93 7 22 10
}
dialog -l mp3.edit {
title "MP3 Edit"
size -1 -1 130 75
option dbu
edit "", 1, 23 5 80 10, multi autovs
text "Title:", 2, 5 6 15 10
edit "", 3, 23 25 80 10, autovs multi
text "Artist:", 4, 5 26 15 10
edit "", 6, 23 45 80 10, autovs multi
text "Album:", 7, 5 46 17 10
button "Update", 5, 38 60 23 10
button "Cancel", 8, 66 60 23 10, cancel
}
on *:dialog:mp3.edit:init:0:{
tokenize 124 $read(playlist.txt,$did(mplayer,56).sel)
var %title $iif($numtok($2,45) > 1,$token($2,2,45),$2), %artist $iif($3,$v1,Unknown), %album $iif($4,$v1,$sound($1).album)
did -a $dname 1 %title
did -a $dname 3 %artist
did -a $dname 6 %album
}
on *:dialog:mp3.edit:sclick:*:{
if ($did == 5) {
tokenize 124 $read(playlist.txt,$did(mplayer,56).sel)
var %title $iif($did(1),$v1,Unknown), %artist $iif($did(3),$v1,Unknown), %album $iif($did(6),$v1,Unknown), %line $did(mplayer,56).sel, %format $iif($readini(mplayer.ini,mp3,song.format),$v1,artist - title)
if ($remove($did(mplayer,36),$chr(32)) == $remove($iif($numtok($2,45) > 1,$token($2,2,45),$2),$chr(32))) {
did -ra mplayer 36 %title
did -ra mplayer 6 %artist
}
write -l $+ %line playlist.txt $+($1,$chr(124),%title,$chr(124),%artist,$chr(124),%album,$chr(124),$5)
loadlist
did -b mplayer 2
dialog -x mp3.edit mp3.edit
}
}
dialog -l mp3.settings {
title "MP3 Settings"
size -1 -1 320 285
option dbu
tab "Display", 6, 2 1 317 281
tab "Other Settings", 18
button "Close", 11, 175 268 30 10, cancel
button "Save and Close", 19, 130 268 42 10, disable
button "Save", 20, 102 268 25 10, disable
;<!-- Tab 6 -->
box "Now Playing Message", 1, 15 25 290 125, tab 6
edit "", 2, 20 40 280 80, read autovs multi vsbar tab 6
edit %bc.format, 3, 20 135 280 10, autohs tab 6
radio "Message", 4, 75 235 30 10, group tab 6
radio "Describe (/me)", 5, 125 235 50 10, tab 6
text "Display format", 7, 20 126 35 8, tab 6
box "Channels to Broadcast", 8, 15 155 290 50, tab 6
text "Seperate channels with a comma. For all channels, type 'all'. for active window only, type 'active'.", 9, 20 170 240 10, tab 6
box "Display Options", 10, 15 210 290 53, tab 6
edit "", 12, 20 185 280 10, tab 6
radio "Enabled", 13, 140 220 45 10, group tab 6
radio "Disabled", 14, 190 220 45 10, tab 6
button "Show what i’m listening to", 15, 38 250 80 10, disable tab 6
text "Automatically display what i'm listening to:" 16, 30 221 110 10, tab 6
text "Display format:", 17, 30 236 40 10, tab 6
;<!-- Tab 18 -->
box "Format For Song List", 22, 15 120 290 90, tab 18
text "List songs in this format:", 23, 30 140 80 10, tab 18
Combo 24, 95 138 50 50, drop tab 18
text "Check for updates every", 25, 20 55 70 10, tab 18
edit "", 26, 85 54 20 10, tab 18 disable
text "Minutes.", 27, 110 55 20 10, tab 18
box "Update settings", 28, 15 25 290 90, tab 18
check "Automatic update", 29, 20 40 50 10, tab 18
text "Strip extra text from title:", 30, 30 170 65 10, tab 18
radio "Yes", 31, 97 169 20 10, group tab 18
radio "No", 32, 120 169 20 10, tab 18
check "Check for Updates when mIRC starts", 33, 20 75 100 10, tab 18
check "Check for Updates when MP3 player starts", 34, 20 95 115 10, tab 18
}
on *:dialog:mp3.settings:init:0:{
var %write = did -a $dname 2 $br
did -a $dname 2 Here are the avaliable options you have for display:
%write &title - Song Title
%write &artist - Song Artist
%write &album - Song Album
%write &genre - Song Genre
%write &year - Song Year
%write &len - Song Length
%write &rem - Time Remaining
%write &playcount - Number of times the song has been played
%write &pos - Song's current position
%write &bitrate - The song's bitrate
%write &mode - How the song is being played
%write &frequency - Frequency of the song
%write &size - Size of the .MP3 file
did -a $dname 12 $readini(mplayer.ini,mp3,bc.chans)
did -c $dname $iif($readini(mplayer.ini,mp3,bc.status) == 1,13,14)
did -c $dname $iif($readini(mplayer.ini,mp3,bc.msg) == describe,5,4)
if ($readini(mplayer.ini,defaults,autoupdate) == $true) {
did -c $dname 29
did -e $dname 26
if ($readini(mplayer.ini,mp3,check.time)) { did -ra $dname 26 $calc($v1 / 60) }
}
if ($readini(mplayer.ini,mp3,check.on.start) == $true) did -c $dname 33
if ($readini(mplayer.ini,mp3,check.on.open) == $true) did -c $dname 34
did -c $dname $iif($readini(mplayer.ini,mp3,strip.title) == $true,31,32)
if ($readini(mplayer.ini,mp3,bc.msg) && $inmp3) { did -e $dname 15 }
if ($readini(mplayer.ini,mp3,song.format)) {
did -ac $dname 24 $v1
did -a $dname 24 Default
}
else did -ac $dname 24 Default
if ($readini(mplayer.ini,mp3,song.format) != artist - title) did -a $dname 24 artist - title
if ($readini(mplayer.ini,mp3,song.format) != title - artist) did -a $dname 24 title - artist
if ($readini(mplayer.ini,mp3,song.format) != title) did -a $dname 24 title
}
on *:DIALOG:mp3.settings:edit:*: {
if ($did) { did -e $dname 19,20 }
}
on *:dialog:mp3.settings:sclick:*:{
if ($did == 24 || $did isnum 13-14 || $did isnum 5-4 || $did isnum 33-34 || $did == 29) { did -e $dname 19,20 }
if ($did isnum 19-20) {
set %bc.format $did(3).text
if (!$did(12)) { remini mplayer.ini mp3 bc.chans }
else writeini mplayer.ini mp3 bc.chans $remove($did(12).text,$chr(32))
if ($did(33).state == 1) writeini mplayer.ini mp3 check.on.start $true
else writeini mplayer.ini mp3 check.on.start $false
if ($did(34).state == 1) writeini mplayer.ini mp3 check.on.open $true
else writeini mplayer.ini mp3 check.on.open $false
if ($did(29).state == 1) writeini mplayer.ini defaults autoupdate $true
else writeini mplayer.ini defaults autoupdate $false
if ($dialog(mplayer)) { did $iif($did(29).state == 1,-c,-u) mplayer 53 }
writeini mplayer.ini mp3 check.time $iif($did(26) isnum,$calc($v1 * 60),300)
if ($did(24) != $readini(mplayer.ini,mp3,song.format)) {
var %x 1, %format $iif($did(24) == default,artist - title,$did(24))
writeini mplayer.ini mp3 song.format %format
while (%x <= $did(mplayer,56).lines) {
if ($exists(whilefix.dll)) { dll whilefix.dll WhileFix }
if ($read(playlist.txt,%x)) {
tokenize 124 $read(playlist.txt,%x)
write -l $+ %x playlist.txt $+($1,$chr(124),$iif($2,$v1,Unknown),$chr(124),$iif($3,$v1,Unknown),$chr(124),$4,$chr(124),$5)
}
inc %x
}
loadlist
}
did -b $dname 19,20
if ($did == 19) {
dialog -x mp3.settings mp3.settings
if ($dialog(mplayer)) { dialog -v mplayer mplayer }
}
noop $input(Settings Successfully Saved,uidk2,Settings)
}
if ($did == 29) {
did $iif($did(29).state == 1,-e,-b) $dname 26
}
if ($did == 13) {
writeini mplayer.ini mp3 bc.status 1
if ($readini(mplayer.ini,mp3,bc.msg) && $inmp3) { did -e $dname 15 }
}
elseif ($did == 14) {
remini mplayer.ini mp3 bc.status
if ($readini(mplayer.ini,mp3,bc.msg) && $inmp3) { did -e $dname 15 }
}
elseif ($did == 15) { mp3broadcast }
elseif ($did == 4) {
writeini mplayer.ini mp3 bc.msg msg
if ($readini(mplayer.ini,mp3,bc.msg) && $inmp3) { did -e $dname 15 }
}
if ($did == 11) { dialog -v mplayer mplayer }
elseif ($did == 5) {
writeini mplayer.ini mp3 bc.msg describe
if ($readini(mplayer.ini,mp3,bc.msg) && $inmp3) { did -e $dname 15 }
}
}
on *:mp3end: { nextsong }
on *:dialog:aboutmp3:init:0: {
did -a $dname 1 MP3 Player
did -a $dname 2 Made by: Anthony1293
did -a $dname 3 No info to display yet
}
on *:dialog:mplayer:menu:*: {
if ($did == 48) {
hadd -m $dname check $true
checkupdate
}
if ($did == 51) {
if ($dialog(aboutmp3)) {
dialog -v aboutmp3 aboutmp3
}
dialog -ma aboutmp3 aboutmp3
}
if ($did == 50) {
if ($dialog(mp3help)) {
dialog -v mp3help mp3help
}
dialog -ma mp3help mp3help
}
if ($did == 53) {
if ($did(53).state == 1) {
did -u $dname 53
writeini mplayer.ini defaults autoupdate $false
timerupdateup off
}
else {
did -c $dname 53
writeini mplayer.ini defaults autoupdate $true
auto.update
}
}
if ($did == 81) {
if (!$dialog(mp3.settings)) {
dialog -md mp3.settings mp3.settings
}
else dialog -v mp3.settings
}
}
on *:dialog:mplayer:close:*: {
if ($dialog(mp3.settings)) { dialog -x mp3.settings mp3.settings }
if ($dialog(aboutmp3)) { dialog -x aboutmp3 aboutmp3 }
if ($dialog(mp3help)) { dialog -x mp3help mp3help }
.timerpos.update -p
}
on *:dialog:mplayer:init:0: {
if ($readini(mplayer.ini,mp3,p.method)) did -c $dname $iif($readini(mplayer.ini,mp3,p.method) == continuous,83,$iif($readini(mplayer.ini,mp3,p.method) == random,84,$iif($readini(mplayer.ini,mp3,p.method) == repeat,85)))
if ($readini(mplayer.ini,defaults,autoupdate) == $true) { did -c $dname 53 }
if ($readini(mplayer.ini,mp3,check.on.start) == $true) { checkupdate }
did -c $dname $iif($readini(mplayer.ini,mp3,sort.by) == title,88,87)
if ($readini(mplayer.ini,defaults,updatemsg) != $false) {
noop $input($vinfo,4,New in version: $pversion)
writeini mplayer.ini defaults updatemsg $false
}
var %a 1
while (%a <= $lines(playlist.txt)) {
var %title $token($read(playlist.txt,%a),2,124), %artist $token($read(playlist.txt,%a),3,124)
did -a $dname 56 $iif($readini(mplayer.ini,mp3,song.format),$replace($v1,artist,%artist,title,%title),%artist - %title)
inc %a
}
did -a $dname 75 Played: 0
did -a $dname 74 Total MP3's: $did(56).lines
did -c $dname 72 $vol(master)
if ($did(56).sel) { did -e $dname 2 }
if ($inmp3) {
tokenize 124 $read(playlist.txt,$readini(mplayer.ini,mp3,songnum))
did -e $dname 79
did -a $dname 75 Played: $iif($readini(mplayer.ini,plays,$replace($inmp3.fname,$chr(32),_)),$v1,0)
did -ra $dname 36 $iif($remove($token($2,1,45),$chr(32)) == $remove($3,$chr(32)),$gettok($2,2-,45),$2)
did -ra $dname 6 $3
did -z $dname 63 0 10000
did -c $dname 56 $readini(mplayer.ini,mp3,songnum)
did -c $dname 63 $calc(($inmp3.pos / $inmp3.length)*10000)
.timerpos.update -r
}
echo 3 -a MP3 Player is now loaded
}
on *:dialog:mplayer:sclick:*: {
if ($did == 1) {
if ($did(1).state == 1) vol -vu1
else vol -vu2
}
if ($did == 2) {
if (!$did(56).seltext) {
noop $input(You must choose a song to edit,wd,Error)
dialog -v mplayer mplayer
did -b $dname 2
}
else {
if ($dialog(mp3.edit)) { dialog -x mp3.edit mp3.edit }
dialog -md mp3.edit mp3.edit
}
}
if ($did == 79) { mp3broadcast }
if ($did == 56) {
did -e $dname 2
did -ra $dname 75 Played: $iif($readini(mplayer.ini,plays,$replace($token($read(playlist.txt,$did(56).sel),1,124),$chr(32),_)),$v1,0)
}
if ($did == 58) {
if (%rplay) did -c $dname 56 $r(1,$did($dname,56).lines)
elseif ($did($dname,56).sel == 1) halt
did -c $dname 56 $calc($v1 - 1)
writeini mplayer.ini mp3 songnum $did($dname,56).sel
mp3play $read(playlist.txt,$readini(mplayer.ini,mp3,songnum))
}
if ($did == 66) { mp3stop }
if ($did == 61) { nextsong next }
if ($did == 59) {
if ($inmp3) {
if (!$inmp3.pause) splay pause
else splay resume
}
}
if ($did == 60) {
if ($inmp3.pause) {
splay resume
}
else {
writeini mplayer.ini mp3 songnum $did(56).sel
mp3play $read(playlist.txt,$readini(mplayer.ini,mp3,songnum))
}
}
if ($did == 62) {
if ($sdir(.,Choose mp3 directory)) {
var %x 1, %d $v1
while ($findfile(%d,*.mp3,%x)) {
if ($exists(whilefix.dll)) { dll whilefix.dll WhileFix }
var %file $findfile(%d,*.mp3,%x), %name $left($nopath(%file),-4), %a $iif($numtok(%name,45) > 1,$token(%name,2,45),%name)
var %title $iif($readini(mplayer.ini,mp3,strip.title) == $true,$iif($token(%a,1,32) isnum,$token(%a,2-,32),%a),%a)
var %artist $iif($sound(%file).artist,$v1,$iif($gettok($nopath(%file),-2,45),$v1,Unknown)), %album $iif($sound(%file).album,$v1,Unknown Album)
write playlist.txt $+(%file,$chr(124),$iif($left(%title,1) == $chr(32),$right(%title,-1),%title),$chr(124),$iif($left(%artist,1) == $chr(32),$right(%artist,-1),%artist),$chr(124),%album,$chr(124),$calc($sound(%file).length / 1000))
inc %x
}
loadlist
did -ra mplayer 74 Total MP3's: $calc(%x -1)
if ($findfile(%d,*,0) > $findfile(%d,*.mp3,0)) { noop $input($calc($v1 - $v2) Files could not be loaded because they are not .mp3 files,wd,Error) | dialog -v mplayer mplayer }
if ($v2 >= 1) did -e mplayer 68,70
}
}
if ($did == 69) {
if ($sfile(*.mp3,Choose an mp3 file to add)) {
var %file $v1, %name $left($nopath(%file),-4), %a $iif($numtok(%name,45) > 1,$token(%name,2,45),%name)
var %title $iif($readini(mplayer.ini,mp3,strip.title) == $true,$iif($token(%a,1,32) isnum,$token(%a,2-,32),%a),%a)
var %artist $iif($sound(%file).artist,$v1,$iif($gettok($nopath(%file),-2,45),$v1,Unknown)), %album $iif($sound(%file).album,$v1,Unknown Album)
write playlist.txt $+(%file,$chr(124),$iif($left(%title,1) == $chr(32),$right(%title,-1),%title),$chr(124),$iif($left(%artist,1) == $chr(32),$right(%artist,-1),%artist),$chr(124),%album,$chr(124),$calc($sound(%file).length / 1000))
loadlist
did -ra mplayer 74 Total MP3's: $did(mplayer,56).lines
did -e mplayer 68,70
}
}
if ($did == 70) {
if (!$did(56).sel) {
noop $input(You did not specify a file to delete.,uwo,Error!)
}
else {
if ($exists(playlist.txt) && $did(mplayer,56).sel) {
var %l = $did(mplayer,56).lines, %s = $did(mplayer,56).sel
if (%l == 1) .remove playlist.txt
else write -dl $+ %s playlist.txt
did -d $dname 56 %s
if (%l) {
if (%s <= %l) did -c $dname 56 %s
else did -c $dname 56 %l
}
did -ra mplayer 74 Total MP3's: %l
}
}
}
if ($did == 68) {
did -b $dname 2,68,70
.remove playlist.txt
did -r mplayer 56
did -ra mplayer 74 Total MP3's: 0
if ($inmp3) mp3stop
}
if ($did == 83) {
did -u $dname 84,85
if ($did(83).state == 0) {
remini mplayer.ini mp3 p.method
}
else writeini mplayer.ini mp3 p.method continuous
}
if ($did == 84) {
did -u $dname 83,85
if ($did(84).state == 0) {
remini mplayer.ini mp3 p.method
}
else writeini mplayer.ini mp3 p.method random
}
if ($did == 85) {
did -u $dname 84,83
if ($did(85).state == 0) {
remini mplayer.ini mp3 p.method
}
else writeini mplayer.ini mp3 p.method repeat
}
if ($did == 3) { loadlist }
if ($did == 87) {
writeini mplayer.ini mp3 sort.by artist
loadlist
}
if ($did == 88) {
writeini mplayer.ini mp3 sort.by title
loadlist
}
}
on *:dialog:mplayer:scroll:*: {
if ($did == 72) {
if ($did(1).state == 1) { vol -vu2 | did -u $dname 1 }
vol -v $did($did).sel
}
if ($did == 63) {
if (!$inmp3) halt
if (!%mp3tseek) {
.timerpos.update -p
set %mp3tseek $true
}
did -ra mplayer 76 $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))
did -ra mplayer 77 $remove($duration($calc(($inmp3.length - $inmp3.pos) /1000),3),00:)
.timermp3tseek -m 1 500 splay seek $int($calc(($did(63).sel /10000) * $inmp3.length)) $chr(124) unset %mp3tseek $chr(124) .timerpos.update -r
}
}
on *:dialog:mplayer:dclick:*: {
if ($did == 56) {
if (!$exists($gettok($read(playlist.txt,$did(56).sel),1,124))) {
noop $input(The file path $iif($gettok($read(playlist.txt,$did(56).sel),1,124),$qt($v1)) Was not found.,wd,Error)
dialog -v mplayer mplayer
halt
}
did -a $dname 63 00:00
writeini mplayer.ini mp3 songnum $did(56).sel
mp3play $read(playlist.txt,$did(56).sel)
}
}
; ############################################
; ## ##
; ## ##
; ## Alias ##
; ## ##
; ## ##
; ############################################
alias mplayer {
echo -a 7Loading MP3 Player.
echo -a -
echo -a 7Please Wait...
echo -a -
if ($dialog(mplayer)) {
echo 4 -a MP3 Player is already open.
echo -a -
echo 14 -a mIRC will now close the current one and re-open a new one.
echo -a -
echo 7 -a Please wait...
dialog -x mplayer mplayer
}
dialog -md mplayer mplayer
}
alias -l loadlist {
if ($dialog(mplayer)) {
did -r mplayer 56
filter -ffct $iif($readini(mplayer.ini,mp3,sort.by) == artist,3,2) 124 playlist.txt playlist.txt
var %x 1
while (%x <= $lines(playlist.txt)) {
if ($exists(whilefix.dll)) { dll whilefix.dll WhileFix }
tokenize 124 $read(playlist.txt,%x)
did -a mplayer 56 $iif($readini(mplayer.ini,mp3,song.format),$replace($v1,artist,$3,title,$2),$3 - $2)
inc %x
}
}
}
alias -l mp3play {
tokenize 124 $1-
if (!$exists($qt($1))) { echo -a $false }
splay $qt($1)
writeini mplayer.ini plays $replace($1,$chr(32),_) $calc($readini(mplayer.ini,plays,$replace($1,$chr(32),_))+1)
if ($readini(mplayer.ini,mp3,bc.status)) mp3broadcast
if ($dialog(mp3.settings)) { did -e mp3.settings 15 }
if ($dialog(mplayer)) {
did -ra mplayer 36 $iif($remove($token($2,1,45),$chr(32)) == $remove($3,$chr(32)),$gettok($2,2-,45),$2)
did -ra mplayer 6 $3
did -ra mplayer 75 Played: $readini(mplayer.ini,plays,$replace($1,$chr(32),_))
did -e mplayer 79,2
did -c mplayer 63 0
did -z mplayer 63 0 10000
timerpos on
}
}
alias -l mp3stop {
if ($inmp3) {
splay stop
did -r mplayer 76,77,36,6
did -z mplayer 63 0 0
did -b mplayer 79
if ($dialog(mp3.settings)) { did -b mp3.settings 15 }
remini mplayer.ini mp3 songnum
timerpos off
}
}
alias -l nextsong {
did -r mplayer 76,36,6,77
var %method $readini(mplayer.ini,mp3,p.method), %songnum $iif($readini(mplayer.ini,mp3,songnum),$v1,$did(mplayer,56).sel), %nextnum $calc(%songnum + 1)
if (%method == continuous) || ($inmp3 && !%method) || (!$inmp3 && $1 == next) {
if (%songnum <= $lines(playlist.txt)) {
writeini mplayer.ini mp3 songnum %nextnum
if ($dialog(mplayer)) did -c mplayer 56 %nextnum
mp3play $read(playlist.txt,%nextnum)
halt
}
remini mplayer.ini mp3 songnum
remini mplayer.ini mp3 p.method
}
if (%method == random) {
if ($lines(playlist.txt) !> 1) { goto off }
:picksong
var %song = $read(playlist.txt)
if ($readn == %songnum) goto picksong
writeini mplayer.ini mp3 songnum $readn
if ($dialog(mplayer)) did -c mplayer 56 $readn
if ($dialog(mp3.settings)) did -b mp3.settings 15
mp3play %song
}
if (%method == repeat) {
mp3play $read(playlist.txt,%songnum)
}
if ($dialog(mplayer)) {
did -z mplayer 63 0 0
did -r mplayer 36,6
if ($did(mplayer,56).sel == %songnum) did -ra mplayer 75 Played: $calc($did(mplayer,75)+1)
}
:off
did -b mplayer 79
if ($dialog(mp3.settings)) { did -b mp3.settings 15 }
timerpos off
remini mplayer.ini mp3 songnum
}
alias -l timerpos {
if ($1 == on) {
.timerpos.update 0 1 did -c mplayer 63 $!calc(( $!insong.pos / $!insong.length)*10000) $chr(124) $&
did -ra mplayer 76 $!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)) $chr(124) $&
did -ra mplayer 77 $!token( $!duration( $!calc(( $!inmp3.length - $!inmp3.pos) /1000),3),2-,58)
}
elseif ($1 == off) .timerpos.update* off
}
alias -l mp3broadcast {
if (!$readini(mplayer.ini,mp3,bc.chans) || !$readini(mplayer.ini,mp3,bc.msg)) {
noop $input(You must set up your display options first. to do this go to: Display -> options,wd,Error) | dialog -v mplayer mplayer | return }
tokenize 124 $read(playlist.txt,$readini(mplayer.ini,mp3,songnum))
var %path $1, %name $2, %artist $3, %title $iif($2,$2,Unknown), %album $4, %len $remove($duration($5,3),00:)
var %rem $remove($duration($calc(($inmp3.length -$inmp3.pos) /1000),3),00:), %bit $sound(%path).bitrate
var %genre $iif($sound($insong.fname).genre, $sound($insong.fname).genre, Unknown genre)
var %size $bytes($file($insong.fname).size).suf, %mode $mp3($insong.fname).mode, %frequency $+($round($calc($mp3($insong.fname).sample / 1000),1)),kHz)
var %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))
var %year $iif($sound($insong.fname).year, $sound($insong.fname).year, Unknown year), %comment $iif($sound($insong.fname).comment, $sound($insong.fname).comment, No comment)
var %msg $replace(%bc.format,&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(mplayer.ini,plays,$replace($inmp3.fname,$chr(32),_)))
if ($readini(mplayer.ini,mp3,bc.chans) == all) $iif($readini(mplayer.ini,mp3,bc.msg) == describe,ame,amsg) %msg
if ($readini(mplayer.ini,mp3,bc.chans) == active) $iif($readini(mplayer.ini,mp3,bc.msg),$readini(mplayer.ini,mp3,bc.msg),msg) $active %msg
else {
tokenize 44 $readini(mplayer.ini,mp3,bc.chans)
var %x 1
while (%x <= $numtok($readini(mplayer.ini,mp3,bc.chans),44)) {
$readini(mplayer.ini,mp3,bc.msg) $gettok($readini(mplayer.ini,mp3,bc.chans),%x,44) %msg
inc %x
}
}
}
; ############################################
; ## ##
; ## ##
; ## Auto Update ##
; ## ##
; ## ##
; ############################################
alias -l ucomplete {
if ($dialog(mplayer)) {
noop $input(Updated $+($1,$chr(32),[,$bytes($2,db) lines - $bytes($3,db) bytes]) Update took: $+($duration($calc($ctime - $4),1)) $+($chr(40),$calc($ticks - $5) MS,$chr(41)),4,Update)
restartmsg
}
else echo 3 -a Updated $+($1,$chr(32),[,$bytes($2,db) lines - $bytes($3,db) bytes]) Update took: $+($duration($calc($ctime - $4),1)) $+($chr(40),$calc($ticks - $5) MS,$chr(41))
}
alias pversion {
return $gettok($remove($read($script,6),$chr(35),$chr(32),$chr(59)),2,58)
}
alias vinfo {
return Error fixed with returning: * /did: invalid parameters in status window. $br(2) $&
New Settings panel added for more options (this can be found in: Options -> Settings) $br(2) $&
Change the way the songs are shown in the list (found in the settings panel) $br(2) $&
More options to edit song display info such as: Artist, album, genre, ect. $br(2) $&
Supports WhileFix.dll to keep mIRC from freezing. found at: http://www.mircscripts.org/comments.php?cid=2617 $br(2) $&
Songs will have to be re-added to your playlist for this update to take effect due to the new features. $br(3) $&
Thank you to our beta testers: Nerf, And Bazeballl for testing out this new update.
}
alias br {
return $iif($1 > 1,$str($crlf $chr(32),$1),$crlf)
}
alias -l cversion {
if ($dialog(mplayer)) {
var %info $input(You already have the current version of this MP3 Player.,4,Error)
if (%info) dialog -v mplayer mplayer
}
else echo 4 -a You already have the current version of this MP3 Player.
}
alias -l restartmsg {
if ($dialog(mplayer)) {
noop $input(The MP3 Player must now be restarted for the updates to take effect.,4,Restart required)
dialog -x mplayer mplayer
echo 3 -a Restarting MP3 Player. Please wait...
echo -a -
timerstartupanel 1 2 dialog -md mplayer mplayer
}
}
alias checkupdate {
var %rnum $ticks, %file $qt($script)
sockopen $+(panelupdate.,%rnum) chaosscript.net 80
sockmark $+(panelupdate.,%rnum) $+(%file,~,$ctime,~,$ticks,~,mplayer)
if ($exists(%file)) { .remove %file }
}
on *:SOCKOPEN:panelupdate.*:{
tokenize 126 $sock($sockname).mark
if ($sockerr) { timer 1 1 $input(Failed to update file: $shortfn($1),wd,Error) }
else {
sockwrite -nt $sockname GET /mp3player/mp3player.mrc HTTP/1.1
sockwrite -nt $sockname Host: $+($sock($sockname).addr,$str($crlf,2))
}
}
on *:SOCKREAD:panelupdate.*:{
tokenize 126 $sock($sockname).mark
var %x 1, %sockreader
if (!$hget($sockname,header)) {
while ($sock($sockname).rq) {
sockread %sockreader
if (!%sockreader) { hadd -m $sockname header $true | goto continue }
}
}
:continue
sockread &sockreader
bwrite $qt($1) -1 -1 &sockreader
}
on *:SOCKCLOSE:panelupdate.*:{
tokenize 126 $sock($sockname).mark
if ($dialog($4).active == $true) {
if ($gettok($remove($read($1,6),$chr(35),$chr(32),$chr(59)),2,58) <= $readini(mplayer.ini,version,current)) {
if ($hget($4,check) == $true) timercversion 1 1 cversion
if ($hget($4,check)) hdel $4 check
}
else {
timerucomplete 1 1 ucomplete $remove($token($1,$numtok($1,92),92),$chr(34)) $lines($1) $lof($1) $2 $3
writeini mplayer.ini version current $gettok($remove($read($1,6),$chr(35),$chr(32),$chr(59)),2,58)
writeini mplayer.ini defaults updatemsg $true
$+($iif($script($1),re),load) -rs $1
}
}
if ($readini(mplayer.ini,defaults,autoupdate) == $true) { auto.update }
}
alias -l auto.update {
.timerupdateup 1 $iif($readini(mplayer.ini,mp3,check.time),$v1,300) checkupdate
}
The lag is from your method of broadcast. The best solution here would be to gather all the info required about the song into variables when it is preparing to play the song in the first place, or if it is already displayed somewhere, use $did()s. When calling for a lot of different tags from MP3s, mIRC tends to lag a lot. My solution to this was to just broadcast the title and artist, since those are the important bits to know anyway.
Since you already have the artist and title gathered up in the dialog anyway, you can use $did() calls to put that into a broadcast, and it will prove much faster than trying to display every little detail.
ok np anthony, that works :) , i also have alot of lag when broadcasting the song, is this a known issue ur working on or is it maybe a conflict with another script ?
sunny, i have 100% no skill in coding lol .. im just puting together a bunch of snippets in an arranged fashion lol ... just learning the basics before i go attempting anything more than a menu lol .. but this mp3 player is 1 of the main features of the script so im just trying to make it a little more capable ...
jarrodkharis: Support could be included for hotkeys using the Function keys up top, but it may interfere with other scripts which also want to use the same keys. In a custom @Window any key could be watched for, but first you would have to make a picwin-based GUI for the MP3 player which would seem a bit much to me, and you would still have to have the @Window selected anyway. My suggestion would be to add your own support for function keys, since supplying some stock may interfere with other things that people have loaded.
alias listname {
var %b 0 , %c $lines($lp_plist) , %x
.fopen -o nlist $lp_nlist
while (%b < %c) {
inc %b
%x = $nopath($read($lp_plist,%b))
.fwrite -n nlist $left(%x,$calc($len(%x) - 4))
}
.fclose *nlist*
}
Above I have posted an alias from my LimePlayer script that handles writing the name list. Notice up top, that .fopen opens up a new file (-o, you could also use -n but it will not overwrite the file if it already exists), and that there is an internal name identified for mIRC's use (nlist). After that, it cycles through everything it needs with a while loop, and .fwrites everything to "nlist". When done, .fclose will release the file from mIRC so it can be opened by other programs again.
Using this format, you can cycle through everything found in your $sdir() check and write it much quicker, as mIRC's standard write command basically opens the file, writes, closes. Repeat and repeat. With fopen and fclose, it will hold it open which greatly reduces the time used on large amounts of data.
Also, by using the $fread() command you can quicken the pace at which mIRC populates the playlist control in the dialog. I would suggest using /filter here, but since it performs an operation on the item being read before doing its did -a, File Handling could benefit this area as well. For $fread(), it will read until the next $crlf-terminated line, so in essence it will read one line of the text at a time, and will automatically read the next area without the need for commanding it to read a specific line. In essence, it's like a record player. If each line in a text file were a song on a record player, it would work the same. It will only cycle through all the "songs", unless you manually placed the "needle" somewhere else using /fseek.
If you need more help with this, use /help /fopen and it will have everything you need on one page. I taught myself file handling just with the help file, so it isn't all that difficult to implement after a couple of reads and test aliases ^_^
SunnyD: There is a standard-looking scrollbar built-in to mIRC. You just never see it used because its use is rather limited as compared to the other features of standard dialogs.
anthony1293: A nice basic mp3 script, looks pretty good. However, might I suggest that rather than using $sfile(), use $msfile() for selecting files? That way, someone could select a single file, or multiple files (say they want MOST of the songs in a directory, but not ALL of them.)
Also, take a look at your writing routine for $sdir(). While no, there is nothing wrong with it, you have noticed that there is a substantial lag when writing a lot of files to your playlist? I myself would suggest that, rather than using a regular write, you /fopen the playlist file, /fwrite all your finds with $sdir(), and then /fclose when done. When I made the switch from regular write to this, there was almost no lag in my MP3 script when creating a playlist (and it creates a second list for song names). It went from maybe 50-65 seconds on my PC to create a ~500 song list (for both), to about 15-20.
SunnyD: no dll's required. however i do plan on adding in a whilefix.dll file that will fix mIRC lagging when adding a large amount of files. also i will be adding more update features for it.
jarrodkharis: I'll surely look into it, it works fine for me but i'll test it further. also i'll look into the errors.