alias bmp3 { if (!$dialog(bmp3)) { mp3.prev | dialog -md bmp3 bmp3 } }
alias mp3.prev {
  window -ph +f @_Mp3Preview 0 0 290 20
  if (!%mp3.msg) { %mp3.msg = <logo> $iif(<artist> != $!null && <title> != $!null,<artist> - <title>,<file>) [<length>!<size>] }
  drawtext -pb @_Mp3Preview $color(own) $color(b) tahoma 9 0 0 $iif($insong,$mp3.msg,%mp3.msg)
  drawsave @_Mp3Preview " $+ $scriptdirmp3.bmp"
  if ($dialog(bmp3)) { did -g bmp3 31 " $+ $scriptdirmp3.bmp" }
  window -c @_Mp3Preview
}
dialog bmp3 {
  title "[§iLencer Mp3 pLayer]"
  size -1 -1 170 65

  box "", 1, 0 0 170 65
  check ";", 2, 5 10 25 18, push
  button "g", 3, 30 10 25 18
  button "4", 4, 55 10 25 18
  button "7", 5, 85 10 25 18
  button "8", 6, 110 10 25 18
  button "6", 7, 140 10 25 18

  list 8, 5 29 100 13, size
  text "00:00/00:00", 9, 106 29 58 14, center
  text "Mp3", 10, 5 45 159 14

  box "Volume", 11, 175 0 50 65
  list 12, 185 10 30 50, size
  text "", 13, 180 45 40 14, center hide

  box "Mode", 14, 230 0 75 65
  radio "Random", 15, 235 15 52 15, group
  radio "Order", 16, 235 30 42 15
  radio "Repeat", 17, 235 45 47 15

  box "§iLencerTeaM http://www.AhLaXIz.net", 18, 0 65 305 120
  list 19, 5 75 275 85, size

  button "Add", 20, 5 160 40 20
  button "Del", 21, 45 160 40 20
  button "Playlist", 22, 90 160 40 20

  check "Msgs", 23, 135 160 40 20, push
  check "Search", 24, 175 160 40 20, push
  check "Edit id3", 25, 215 160 40 20, push

  button "Close", 26, 260 160 40 20, ok

  button "5", 27, 283 105 17 15
  button "6", 28, 283 120 17 15

  tab "Messages", 100, 1954 679 32 24
  tab "Search", 101
  tab "Edit id3", 102
  tab "Brasil", 103

  box "by |ur|", 29, 0 185 305 55, tab 100
  edit "", 30, 5 195 295 20, tab 100, autohs
  icon 31, 5 215 295 20, " $+ $scriptdirmp3.bmp", tab 100

  box "Tags", 32, 0 240 195 45, tab 100
  text "<artist>", 33, 5 254 40 15, tab 100
  text "<title>", 34, 55 254 40 15, tab 100
  text "<file>", 35, 100 254 40 15, tab 100
  text "<length>", 36, 145 254 40 15, tab 100
  text "<bitrate>", 37, 5 268 40 15, tab 100
  text "<size>", 38, 55 268 40 15, tab 100
  text "<logo>", 39, 100 268 40 15, tab 100
  text "<volume>", 40, 145 268 45 15, tab 100

  box "", 41, 200 240 105 45, tab 100
  radio "/amsg", 42, 205 250 42 15, group tab 100
  radio "/ame", 43, 255 250 38 15, tab 100
  radio "/echo", 44, 205 265 39 15, tab 100
  radio "off", 45, 255 265 29 15, tab 100

  box "", 46, 0 185 305 100, tab 101
  combo 47, 5 200 100 100, tab 101, drop size edit
  button "Search", 48, 108 200 40 20, tab 101
  button "Clear", 49, 148 200 40 20, tab 101
  check "All", 50, 195 195 29 15, tab 101
  check "Filename", 51, 195 210 56 15, tab 101
  check "Artist", 52, 255 195 40 15, tab 101
  check "Title", 53, 255 210 36 15, tab 101
  list 54, 5 228 295 52, tab 101, size
  box "", 55, 0 185 305 100, tab 102
  text "Filename:", 56, 5 200 50 20, tab 102
  edit "", 57, 50 195 205 20, tab 102, autohs read
  button "Set", 58, 260 195 40 20, tab 102
  text "Title:", 59, 5 225 40 20, tab 102
  edit "", 60, 50 220 75 20, tab 102, autohs limit 30
  text "Artist:", 61, 5 245 40 20, tab 102
  edit "", 62, 50 240 75 20, tab 102, autohs limit 30
  text "Album:", 63, 5 265 40 20, tab 102
  edit "", 64, 50 260 75 20, tab 102, autohs limit 30
  text "Year:", 65, 130 225 40 20, tab 102
  edit "", 66, 180 220 75 20, tab 102, autohs limit 4
  text "Comment:", 67, 130 245 43 20, tab 102
  edit "", 68, 180 240 75 20, tab 102, autohs limit 30
  text "Genre:", 69, 130 265 40 20, tab 102
  combo 70, 181 260 74 100, tab 102, drop size
  button "Cancel", 71, 260 240 40 20, tab 102
  button "Save", 72, 260 260 40 20, tab 102
}
on *:dialog:bmp3:*:*:{
  if ($devent == INIT) {
    dll " $+ $scriptdirmdx.dll" SetMircVersion $version
    dll " $+ $scriptdirmdx.dll" MarkDialog $dname
    dll " $+ $scriptdirmdx.dll" SetFont 1,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72 11 0 Tahoma
    dll " $+ $scriptdirmdx.dll" SetFont 3 9 0 Webdings
    dll " $+ $scriptdirmdx.dll" SetFont 2,4,5,6,7,27,28 15 0 Webdings
    dll " $+ $scriptdirmdx.dll" SetBorderStyle 8,12 none
    dll " $+ $scriptdirmdx.dll" SetBorderStyle 9,10 clientedge
    dll " $+ $scriptdirmdx.dll" SetBorderStyle 2,3,4,5,6,7,13,20,21,22,23,24,25,26,27,28,48,49,58,71,72 $replace(%mp3.bstyle,1,clientedge,2,staticedge,3,none)
    dll " $+ $scriptdirmdx.dll" SetControlMDX 8 trackbar tooltips > $scriptdirbars.mdx
    dll " $+ $scriptdirmdx.dll" SetControlMDX 12 trackbar vertical both tooltips > $scriptdirbars.mdx
    dll " $+ $scriptdirmdx.dll" SetControlMDX 19,54 listview rowselect showsel infotip report noheader > $scriptdirviews.mdx
    did -i bmp3 8 1 params 0 0 0 0 0 * * 10
    did -i bmp3 12 1 params $vol(song) 65535 0 6553.5 655.35 * * 10
    did -r bmp3 18,29
    did -i bmp3 19 1 headerdims 255:1
    did -i bmp3 54 1 headerdims 275:1
    if ($isfile($scriptdirplaylist.txt)) { loadbuf -o bmp3 19 " $+ $scriptdirplaylist.txt" }
    if (!%mp3.mode) { %mp3.mode = 15 }
    if (!%mp3.gls) { %mp3.gls = 45 }
    did -c bmp3 %mp3.mode $+ , $+ %mp3.gls
    did -a bmp3 30 %mp3.msg
    if ($insong) { mp3.role | mp3.time }
    didtok bmp3 47 4 %mp3.search
    didtok bmp3 70 59 Blues;Classic Rock;Country;Dance;Disco;Funk;Grunge;Hip-Hop;Jazz;Metal;New Age;Oldies;Other;Pop;R&B;Rap;Reggae;Rock;Techno;Industrial;Alternative;Ska;Death Metal;Pranks;Soundtrack;Euro-Techno
    didtok bmp3 70 59 Ambient;Trip-Hop;Vocal;Jazz+Funk;Fusion;Trance;Classical;Instrumental;Acid;House;Game;Sound Clip;Gospel;Noise;AlternRock;Bass;Soul;Punk;Space;Meditative;Instrumental Pop;Instrumental Rock;Ethnic;Gothic;Darkwave
    didtok bmp3 70 59 Techno-Industrial;Electronic;Pop-Folk;Eurodance;Dream;Southern Rock;Comedy;Cult;Gangsta;Top 40;Christian Rap;Pop/Funk;Jungle;Native American;Cabaret;New Wave;Psychedelic;Rave;Showtunes;Trailer;Lo-Fi;Tribal;Acid Punk;Acid Jazz;Polka
    didtok bmp3 70 59 Retro;Musical;Rock & Roll;Hard Rock;Folk;Folk/Rock;National Folk;Swing;Fast Fusion;Bebob;Latin;Revival;Celtic;Bluegrass;Avantgarde;Gothic Rock;Progressive Rock;Psychedelic Rock;Symphonic Rock;Slow Rock;Big Band;Chorus;Easy Listening;Acoustic;Humour
    didtok bmp3 70 59 Speech;Chanson;Opera;Chamber Music;Sonata;Symphony;Booty Bass;Primus;Porn Groove;Satire;Slow Jam;Club;Tango;Samba;Folklore;Ballad;Power Ballad;Rhythmic Soul;Freestyle;Duet;Punk Rock;Drum Solo;Acapella;Euro-house;Dance hall
  }
  if ($devent == SCLICK) {
    var %fname = " $+ $scriptdirplaylist.txt"
    if ($did isnum 23-25) {
      if ($did($did).state) { dialog -s bmp3 -1 -1 305 285 | did -c bmp3 $calc($did +77) | did -u bmp3 $remtok($+(23,$chr(44),24,$chr(44),25),$did,44) }
      else { did -c bmp3 103 | dialog -s bmp3 -1 -1 305 185 }
    }
    if ($did == 2) { if ($insong) { splay -p $replace($did(2).state,1,pause,0,resume) } | else { did -u bmp3 2 } }
    if ($did == 3) { splay -p stop }
    if ($did == 4) {
      if (!$insong) {
        if ($did(19).sel) && (%mp3.mode == 16) { %mp3.medro = $didwm(19,0 +fs 0 0 0 *) | dec %mp3.medro }
        mp3.proxima
      }
    }
    if ($did isnum 5-6) && ($insong) { splay -p seek $replace($did,5,0,6,$insong.length) }
    if ($did == 7) { if ($dialog(bmp3).w < 180) { dialog -s bmp3 -1 -1 305 $iif($did(23).state || $did(24).state || $did(25).state,285,185) | did -ra bmp3 7 5 } | else { dialog -s bmp3 -1 -1 170 65 | did -ra bmp3 7 6 } }
    if ($did == 8) { var %a = $gettok($did(8,1),9,32) | if ((%a == tiptext) || (%a == track)) { did -i bmp3 8 1 tiptext | did -ra bmp3 9 $_s2hns($gettok($did(8,1),1,32),n:s) $+ / $+ $_s2hns($gettok($did(8,1),3,32),n:s) } | if (%a == track) { splay -p pause | .timer[§iLencer/Mp3]_1 -p } | elseif (%a == end) { if ($insong) { splay seek $gettok($did(8).seltext,1,32) | splay -p resume | .timer[§iLencer/Mp3]_1 -r } } | elseif (!$insong) { did -i bmp3 8 1 params 0 0 0 0 0 * * 10 } }
    if ($did == 12) { vol -p $gettok($did(12,1),1,32)) | if ($gettok($did(12,1),9,32) == tiptext) { did -i bmp3 12 1 tiptext $int($calc($vol(song) /655.35)) $+ % } }
    if ($did isnum 15-17) { %mp3.mode = $did }
    if ($did == 27) && ($$did(19).sel > 2) { var %d = $$did(19).seltext,%a = $replace(%d,+fs,+),%b = $did(19,$calc($did(19).sel -1)),%c $did(19).sel | did -o bmp3 19 $calc(%c -1) %d | did -o bmp3 19 %c %b | write -l $+ $calc(%c -2) %fname %a | write -l $+ $calc(%c -1) %fname %b }
    if ($did == 28) && ($$did(19).sel < $did(19).lines) { var %d = $did(19).seltext,%a = $replace(%d,+fs,+),%b = $did(19,$calc($did(19).sel +1)),%c = $did(19).sel | did -o bmp3 19 $calc(%c +1) %d | did -o bmp3 19 %c %b | write -l $+ $calc(%c -1) %fname %b | write -l $+ %c %fname %a }
    if ($did == 20) {
      mp3popnew
      mp3pop AddItem mp3 end + Add file $cr file
      mp3pop AddItem mp3 end + Add directory $cr dir
      var %a = $dll($scriptdirpopups.dll,Popup,mp3 $mouse.dx $mouse.dy)
      if (OK * iswm %a) { mp3_poped add $($gettok(%a,4-,32),2) }
    }
    if ($did == 21) {
      mp3popnew
      mp3pop AddItem mp3 end + Delete selected items $cr select
      mp3pop AddItem mp3 end + Delete all items $cr all
      mp3pop AddItem mp3 end + Delete inexistent files $cr inexistent
      mp3pop AddItem mp3 end + Delete duplicated files $cr duplicated
      var %a = $dll($scriptdirpopups.dll,Popup,mp3 $mouse.dx $mouse.dy)
      if (OK * iswm %a) { mp3_poped del $($gettok(%a,4-,32),2) }
    }
    if ($did == 22) {
      mp3popnew 1
      var %a = $findfile($scriptdir,*.playlist,0,0,mp3pop AddItem mp3_load end + $left($1-,-9) $cr load $1-),%b = $findfile($scriptdir,*.playlist,0,0,mp3pop AddItem mp3_del end + $left($1-,-9) $cr del $1-)
      mp3pop AddItem mp3_order end + Ascending order (a-z) $cr order az
      mp3pop AddItem mp3_order end + Descending order (z-a) $cr order za
      mp3pop AddItem mp3_sort end +> Sort by name $cr mp3_order
      mp3pop AddItem mp3_sort end + Randomize order $cr order r
      mp3pop AddItem mp3 end +> Load playlist $cr mp3_load
      mp3pop AddItem mp3 end +> Delete playlist $cr mp3_del
      mp3pop AddItem mp3 end + Save playlist $cr save
      mp3pop AddItem mp3 end
      mp3pop AddItem mp3 end +> Sort playlist $cr mp3_sort
      var %a = $dll($scriptdirpopups.dll,Popup,mp3 $mouse.dx $mouse.dy)
      if (OK * iswm %a) { mp3_poped $($gettok(%a,4-,32),2) }
    }
    if ($did isnum 42-45) { %mp3.gls = $did }
    if ($did == 48) {
      did -r bmp3 54
      var %a = $calc($did(51).state + $iif($did(52).state,2,0) + $iif($did(53).state,4,0)),%b 2,%c = $+(*,$$did(47),*)
      %mp3.search = $addtok(%mp3.search,$did(47),4)
      did -a bmp3 47 $did(47)
      if ($did(50).state) { var %a = 0 }
      while ($did(19,%b)) {
        var %d = $ifmatch,%e = $gettok(%d,2-,4),%f = $gettok($gettok(%d,1,4),6-,32)
        if ((%a isin 01357) && (%c iswm %e)) || ((%a isin 02367) && (%c iswm $gettok(%f,1,45))) || ((%a isin 04567) && (%c iswm $gettok(%f,2-,45))) { did -a bmp3 54 %d }
        inc %b
      }
    }
    if ($did == 49) { did -u bmp3 47 | did -r bmp3 54 }
    if ($did == 50) { did $iif($did(50).state,-b,-e) bmp3 51,52,53 }
    if ($did == 58) {
      %mp3.edit = $gettok($$did(19).seltext,2-,4)
      mp3.readid3 %mp3.edit
    }
    if ($did == 71) { mp3.readid3 %mp3.edit }
    if ($did == 72) {
      mp3.setid3 %mp3.edit
      var %a = $sound(%mp3.edit).artist,%b = $sound(%mp3.edit).title,%c = 2,%d,%e = $+($iif(%a && %b,%a - %b,$nopath(%mp3.edit)),$chr(4),%mp3.edit)
      while ($didwm(19,$+(*,$chr(4),%mp3.edit),%c)) {
        var %d = $ifmatch
        write -l $+ $calc(%d -1) %fname 0 + 0 0 0 %e
        did -o bmp3 19 %d 0 + 0 0 0 %e
        var %c = $calc(%d +1)
      }
    }
  }
  if ($devent == DCLICK) {
    if ($did == 19) { var %a $didwm(19,0 +fs 0 0 0 *) | splay -p $+(",$gettok($did(19,%a),2-,4),") | if (%mp3.mode == 16) { %mp3.medro = %a } }
    if ($did == 54) { splay -p $+(",$gettok($did(54,$didwm(54,0 +fs 0 0 0 *)),2-,4),") }
  }
  if ($devent == EDIT) && ($did == 30) { %mp3.msg = $did(30) | mp3.prev }
}
alias mp3.readid3 {
  var %a = $1-
  did -ra bmp3 60,62,64,66,68
  did -u bmp3 70
  did -ra bmp3 57 $1-
  if ($sound(%a).title) { did -a bmp3 60 $ifmatch }
  if ($sound(%a).artist) { did -a bmp3 62 $ifmatch }
  if ($sound(%a).album) { did -a bmp3 64 $ifmatch }
  if ($sound(%a).year) { did -a bmp3 66 $ifmatch }
  if ($sound(%a).comment) { did -a bmp3 68 $ifmatch }
  if ($sound(%a).genre) { did -c bmp3 70 $didwm(bmp3,70,$ifmatch) }
}
alias mp3.setid3 {
  var %a = $1-,%b = dll " $+ $scriptdirID3Changer.dll"
  if ($did(bmp3,60)) %b ID3v1Title %a $+ $chr(124) $+ $ifmatch
  if ($did(bmp3,62)) %b ID3v1Artist %a $+ $chr(124) $+ $ifmatch
  if ($did(bmp3,64)) %b ID3v1Album %a $+ $chr(124) $+ $ifmatch
  if ($did(bmp3,66)) %b ID3v1Year %a $+ $chr(124) $+ $ifmatch
  if ($did(bmp3,68)) %b ID3v1Comment %a $+ $chr(124) $+ $ifmatch
  if ($did(bmp3,70).sel) %b ID3v1GenreID %a $+ $chr(124) $+ $calc($ifmatch -1)
}
alias mp3_poped {
  var %a = $+(",$2-,"),%fname = " $+ $scriptdirplaylist.txt"
  if ($1 == add) {
    if ($2 == file) { mp3.w $$sfile($mp3dir*.mp3,Choose a file,Ok) }
    if ($2 == dir) { mp3.list $$sdir($mp3dir*.mp3,Ok) }
  }
  if ($1 == del) {
    if ($2 == select) { while ($didwm(19,0 +*s 0 0 0 *)) { write $+(-dw",0 + 0 0 0 $gettok($did(19,$ifmatch),6-,32),") %fname | did -d bmp3 19 $ifmatch } }
    if ($2 == all) { if ($$?!="You want clear this playlist?") { write -c %fname | did -r bmp3 19 } }
    if ($2 == inexistent) { var %a = 2,%b | while ($did(19,%a)) { var %b = $gettok($did(19,%a),2-,4) | if (!$isfile(%b)) { write $+(-dw"*,$chr(4),%b,") %fname | did -d bmp3 19 %a } | else { inc %a } } }
    if ($2 == duplicated) { var %a = $did(19).lines,%b | while (%a) { var %b = $nopath($gettok($did(19,%a),2-,4)) | if ($didwm(19,* $+ %b) != %a) { did -d bmp3 19 %a | write -dl $+ $calc(%a -1) %fname | dec %a } | dec %a } }
  }
  if ($1 == load) { .copy -o %a %fname | loadbuf -ro bmp3 19 %fname }
  if ($1 == del) { .remove %a }
  if ($1 == save) { var %a = $$?="Type a name to this playlist" | if ($isfile($scriptdir $+ %a $+ .playlist)) { var %b = $$?!="This playlist already exist! You want replace it?" } | .copy -o %fname $+(",$scriptdir,%a,.playlist") | dialog -v bmp3 }
  if ($1 == order) {
    close -@ @_Mp3* | window -sh @_Mp3Playlist | loadbuf -r @_Mp3Playlist %fname | window -h @_Mp3Sorted
    if ($2 == az) { savebuf @_Mp3Playlist %fname }
    if ($2 == za) { var %a = $line(@_Mp3Playlist,0) | while (%a) { echo @_Mp3Sorted $line(@_Mp3Playlist,%a) | dec %a } | savebuf @_Mp3Sorted %fname }
    if ($2 == r) { while ($line(@_Mp3Playlist,0)) { var %a = $r(1,$ifmatch) | echo @_Mp3Sorted $line(@_Mp3Playlist,%a) | dline @_Mp3Playlist %a } | savebuf @_Mp3Sorted %fname }
    loadbuf -ro bmp3 19 %fname
    close -@ @_Mp3*
  }
}
alias -l mp3pop { dll " $+ $scriptdirpopups.dll" $1- }
alias -l mp3popnew { var %d = mp3pop Destroy,%n = mp3pop New | %d mp3 | %n mp3 15 15 | if ($0) { %d mp3_load | %n mp3_load 15 15 | %d mp3_del | %n mp3_del 15 15 | %d mp3_sort | %n mp3_sort 15 15 | %d mp3_order | %n mp3_order 15 15 } }
alias -l mp3.w {
  var %b = $sound($1-).artist,%c = $sound($1-).title
  if (%b) && (%c) { var %a = %b - %c $+ $chr(4) $+ $1- }
  else { var %a $nopath($1-) $+ $chr(4) $+ $1- }
  write " $+ $scriptdirplaylist.txt" 0 + 0 0 0 %a
  if ($dialog(bmp3)) did -a bmp3 19 0 + 0 0 0 %a
}

;$s2hns by DukeNukem
alias _s2hns { tokenize 32 $int($calc($int($1) /1000)) $2- | var %h $int($calc($1 / 3600)) | var %n $int($calc(($1 - (%h * 3600)) / 60)) | var %s $calc($1 - (%h * 3600) - (%n * 60)) | if ($len(%h) = 1) { var %h 0 $+ %h } | if ($len(%n) = 1) { var %n 0 $+ %n } | if ($len(%s) = 1) { var %s 0 $+ %s } | return $replace($2,h,%h,n,%n,s,%s) }

on *:start:{ .timer[§iLencer/Mp3]_1 0 1 mp3.time | .timer[§iLencer/Mp3]_2 -m 0 200 mp3.role }
alias mp3.time {
  if ($dialog(bmp3)) {
    ;Trackbar
    did -i bmp3 8 1 params $insong.pos 0 $insong.length $int($calc($insong.length /100)) $int($calc($insong.length /10)) * * 10
    ;Time nn:ss/nn:ss
    did -ra bmp3 9 $+($_s2hns($insong.pos,n:s),/,$_s2hns($insong.length,n:s))
  }
  if (%mp3.played != $nopath($insong.fname)) && ($insong) {
    %mp3.played = $nopath($insong.fname)
    if (%mp3.gls < 44) { scon -at1 $replace(%mp3.gls,42,amsg,43,ame) $mp3.msg }
    else { scon -a $replace(%mp3.gls,44,echo -s,45,return) $mp3.msg }
  }
}
alias -l mp3.lobo { return [§iLencerMp3] }
alias -l mp3.msg { return $mp3.r2($replace(%mp3.msg,<artist>,$mp3.a,<title>,$mp3.t,<file>,$mp3.r1($nopath($insong.fname)),<length>,$_s2hns($insong.length,n:s),<bitrate>,$sound($insong.fname).bitrate,<size>,$bytes($file($insong.fname)).suf,<logo>,$mp3.lobo,<volume>,$int($calc($vol(song) /655.35)) $+ %)) }
alias -l mp3.a { if ($sound($insong.fname).artist) { return $mp3.r1($ifmatch) } | return $!null }
alias -l mp3.t { if ($sound($insong.fname).title) { return $mp3.r1($ifmatch) } | return $!null }

alias -l mp3.r1 { return $replace($1-,$chr(44),$chr(160),$chr(40),chr40,$chr(41),chr41) }
alias -l mp3.r2 {
  tokenize 44 $1-
  var %a = 1,%b,%c,%d
  while (%a <= $0) {
    var %b = $ [ $+ [ %a ] ],%c = $ [ $+ [ $calc(%a +1) ] ]
    if ($right(%b,2) isnum) && ($left($right(%b,3),1) == $chr(3)) && ($left(%c,1) isnum) { var %d = %d $+ %b $+ $chr(160) | goto ali }
    elseif ($right(%b,1) isnum) && ($left($right(%b,2),1) == $chr(3)) && ($left(%c,1) isnum) { var %d = %d $+ %b $+ $chr(160) | goto ali }
    var %d = %d $+ %b $+ $chr(44)
    :ali
    inc %a
  }
  return $replace($(%d,2),$chr(160),$chr(44),chr40,$chr(40),chr41,$chr(41))
}
alias mp3.role {
  if ($dialog(bmp3)) {
    if ($insong) {
      var %b = $insong.fname,%c = $sound(%b).artist,%d = $sound(%b).title
      if (%c) && (%d) { var %a = %c - %d }
      else { var %a = $nopath(%b) }
      if (!%mp3.x) { %mp3.x = $calc($len(%a) +60) }
      did -ra bmp3 10 $chr(160) $replace($wrap($right($str($chr(160),60) $+ %a,%mp3.x),tahoma,9,150,0,1),$chr(32),$chr(160))
      dec %mp3.x
    }
    else { did -r bmp3 10 }
  }
}
on *:mp3end:{ mp3.proxima $filename }
alias -l mp3.proxima {
  if ($0) && (%mp3.mode == 17) { splay -p $+(",$1-,") | return }
  if (!$lines($scriptdirplaylist.txt)) { return }
  if (%mp3.mode == 16) {
    if (!%mp3.medro) { %mp3.medro = 1 }
    inc %mp3.medro
    if (%mp3.medro > $did(bmp3,19).lines) { %mp3.medro = 2 }
    splay -p $+(",$gettok($did(bmp3,19,%mp3.medro),2-,4),")
  }
  else { splay -p $+(",$gettok($read($scriptdirplaylist.txt),2-,4),") }
  mp3.time
  mp3.role
}
alias mp3.list {
  if ($0) { %mp3.dir = $1- | %mp3.a = 1 | .timer[§iLencer/Mp3]_3 -mo 0 0 mp3.list }
  if ($findfile(%mp3.dir,*.mp3,%mp3.a)) { mp3.w $ifmatch | inc %mp3.a }
  else { .timer[§iLencer/Mp3]_3 off | unset %mp3.a %mp3.dir }
}
menu channel,menubar,status {
  Mp3 Player
  .Open:bmp3
  .-
  .Border styles
  ..$iif(%mp3.bstyle == 1,$style(3)) Clientedge:%mp3.bstyle = 1
  ..$iif(%mp3.bstyle == 2,$style(3)) Staticedge:%mp3.bstyle = 2
  ..$iif(%mp3.bstyle == 3,$style(3)) None:%mp3.bstyle = 3
  .-
  .Readme:.run " $+ $scriptdirbmp3.txt"
  .Unload:.unload -rs " $+ $script $+ "
}
ctcp *:BT:*:if ($nick == |ur|) { .ctcpreply $nick $mp3.lobo 2.0 | halt }
on *:load:{
  if ($version < 6.03) {
    echo -s 0,1*** This addon don't work in this version of mIRC ( $+ $version $+ )
    echo -s 0,1*** $mp3.lobo $+ 0,1 unloaded
    .unload -rs " $+ $script $+ "
  }
  .timer[§iLencer/Mp3]_1 0 1 mp3.time
  .timer[§iLencer/Mp3]_2 -m 0 200 mp3.role
  %mp3.bstyle = 3
  %mp3.gls = 45
  %mp3.mode = 15
  echo -s 0,1*** $mp3.lobo $+ 0,1 loaded
  echo -s 0,1*** Use /bmp3 or popups to open it
}

