mp3

By Rebellious on Dec 29, 2007

Yes, I know it isn't the MDX version of the player I was going to release. That project has been halted till further notice.

Anyway, this version is a simplistic mp3 player I've been working on slowly for the past few days. It features many options; your normal mp3 controls, a volume toggler, a search feature, spam messaging, playlist managing, and an easy interface. The options can be found via menus at the top of the dialog.

The 'previous' option will basically browse through your mp3 history and play through previous mp3s. Nothing else is really different control wise.

The volume toggler can be found in a separate dialog, but the search feature is in the mp3; just hidden at first. Spam messaging will automatically message the active window, and is based off of a variety of tags that you can use in the spam message.

I guess you can just take a look and experiment yourselves. Hoping to receive positive feedback on this mp3!

Critcism, flames, comments, suggestions are all welcome.

Cheers ~ Rebellious

;#############################
;### Rebellious mp3 console ##
;### By Rebellious ###########
;### /mp3c to start ##########
;## Tags for the above: ######
;### -d: opens on desktop ####
;### -o: puts ontop ##########
;### -do: desktop & ontop ####
;#############################

menu channel { 
  rMp3 console:mp3c -d
}

;#### ALIAS #####

alias mp3c dialog $+($iif(!$dialog(mp3c),-m,-v),$iif(*d* iswm $1,d),$iif(*o* iswm $1,o,n)) mp3c mp3c
alias -l rcon return $readini($+(",$scriptdirmp3con.ini,"),$1,$2-)
alias -l wcon writeini $+(",$scriptdirmp3con.ini,") $1 $2 $3-

alias -l mp3cut return $iif($len($1-) > 47,$left($1-,47) $+ ...,$1-)
alias -l mp3cf { 
  var %z = $regsubex($nopath($insong.fname),/.[^.]+$/,$null)
  if ($gettok(%z,1,32) isnum) %z = $deltok(%z,$iif($gettok(%z,2,32) = -,1-2,1),32)
  return %z
}

alias -l artist { 
  var %p = $iif($mp3($insong.fname).artist,$ifmatch,$iif($gettok($sound($insong.fname,TPE1).tag,2-,254),$ifmatch,$sound($insong.fname,TPE1).tag))
  return $iif($count(%p,$chr(32)) > 10,$remove(%p,$chr(32)),%p)
}

alias -l length return $gmt($iif($insong,$calc($mp3($insong.fname).length / 1000)),nn:ss)
alias -l pos return $gmt($iif($insong,$calc($insong.pos /1000)),nn:ss)

alias -l mp3.loadinfo { 
  if ($insong) { 
    .did -ra mp3c 10 $mp3cut($mp3cf)
    .did -ra mp3c 7 $+($pos,$chr(47),$length)
    .did -ra mp3c 9 $mp3($insong.fname).bitrate kbps / $round($sound($insong.fname).sample,0) Hz / $bytes($file($insong.fname).size).suf 
  }
}

alias -l mp3.seek { 
  inc %insong.pos 1 
  .did -c mp3c 11 %insong.pos
  .did -ra mp3c 7 $+($pos,$chr(47),$length)
}

alias -l mp3.didcheck { 
  if ($dialog(mp3c)) { 
    ;; MODE checking
    var %t = $rcon(playsettings,end)

    if (%t = continuous) .did -c mp3c 38
    elseif (%t = repeat) .did -c mp3c 39
    elseif (%t = shuffle) .did -c mp3c 40
    elseif (%t = none) .did -c mp3c 48

    ;; OTHER OPTIONS CHECKING

    if ($rcon(optsetting,stpf) = true) .did -c mp3c 50 
    if ($rcon(optsetting,apwl) = true) .did -c mp3c 55
  }
}

alias -l quickstop { 
  .timermp3 off
  .did -c mp3c 11 1
  .unset %insong.pos
}

; SKIP/PREV/PLAY local command

alias -l spr { 
  var %s = $read($+(",$scriptdirmp3cplaylist.play,"),w,$+(*,$did(mp3c,13).seltext,*))
  if (%s) { 
    .splay -p %s
    if ($did(mp3c,1).enabled != $true) .did -e mp3c 1
    mp3.loadinfo
    .did -z mp3c 11 1 $round($calc($mp3($insong.fname).length / 1000),0)
    .timermp3 0 1 mp3.seek
    if ($rcon(playsettings,spammsg) != null) { 
      msg $active $replace($v1,&title,$mp3cf,&artist,$artist,&bitrate,$mp3($insong.fname).bitrate,&sample, $&
        $mp3($insong.fname).sample,&length,$length,&size,$bytes($file($insong.fname).size).suf, $&
        &b,,&u,,&c,)
    }
  }
}

dialog mp3c {
  title "MP3 Console"
  size -1 -1 140 111
  option dbu notheme
  button "< Prev", 1, 2 97 25 12, disable
  button "Play", 2, 30 97 25 12
  button "Pause", 3, 58 97 25 12
  button "Stop", 4, 86 97 25 12
  button "Next >", 5, 114 97 25 12
  list 13, 2 37 136 58, hsbar vsbar size
  box "", 6, 1 1 136 25
  text "00:00/00:00", 7, 3 6 46 9, disable center
  text "0kbps / 0 Hz / 0 MB ", 9, 51 6 83 9, disable center
  text "Standing by...", 10, 3 16 130 8, center
  scroll "", 11, 8 27 123 8, horizontal top
  edit "", 30, 4 114 108 10
  button "!", 36, 116 112 14 12
  menu "File", 20
  menu "Modules", 17, 20
  item "Toggle volume", 31, 17
  item "break", 32, 17
  item "Search", 33, 17
  item "break", 18, 20
  menu "Add", 19, 20
  item "File", 27, 19
  item "break", 28, 19
  item "Directory", 29, 19
  item "Remove selected", 21, 20
  menu "Playlist", 23
  item "Save Current", 12, 23
  item "break", 222, 23
  item "Load playlist", 14, 23
  item "break", 15, 23
  item "Clear", 16, 23
  menu "Options", 8
  menu "Mode", 24, 8
  item "Continuous", 38, 24
  item "break", 35, 24
  item "Repeat", 39, 24
  item "Shuffle", 40, 24
  item "break", 37, 24
  item "None", 48, 24
  item "break", 25, 8
  item "Set spam message", 34, 8
  menu "Other", 49, 8
  item "Start playing when a file is loaded", 50, 49
  item "break", 54, 49
  item "Append playlist when loaded", 55, 49
}

on *:dialog:mp3c:sclick:1:{ 
  if (!$did(mp3c,13,1)) { 
    did -ra mp3c 4 No playlist!
    return
  }
  var %x = $hget(lastplayedmp3,0).item
  if (%x = 0) { 
    .did -b mp3c 1 
    return
  }
  .did -c mp3c 13 $didwm(mp3c,13,$+(*,$hget(lastplayedmp3,%x).item,*))
  .hdel lastplayedmp3 $hget(lastplayedmp3,%x).item
  .spr
}

on *:dialog:mp3c:close:0:{ 
  if ($insong) { 
    .quickstop
    .splay -p stop
  }
  if ($hget(lastplayedmp3)) .hfree lastplayedmp3
}

on *:dialog:mp3c:sclick:2:{ 
  if ($insong) .hadd -m lastplayedmp3 $mp3cf
  .quickstop
  if (!$did(mp3c,13,1)) { did -ra mp3c 4 No playlist! }
  elseif ($did(mp3c,13).sel) { spr }
  else { 
    .did -c mp3c 13 $r(1,$did(mp3c,13).lines)  
    spr
  }
}

on *:dialog:mp3c:sclick:3:{
  if ($insong) { 
    if ($insong.pause) { 
      .splay -p resume
      .did -ra mp3c 3 Pause
      .timermp3 -r
      .did -ra mp3c 10 $mp3cut($mp3cf)
    }
    else {
      .splay -p pause
      .did -ra mp3c 3 Resume
      .did -ra mp3c 10 $mp3cut($+([Paused],$chr(32),$mp3cf))
      .timermp3 -p
    }
  }
  else { .did -ra mp3c 10 No song is playing... }
}

on *:dialog:mp3c:sclick:4:{ 
  if ($insong) {
    .hadd -m lastplayedmp3 $mp3cf
    .splay -p stop
    .quickstop
    .did -ra mp3c 3 Pause
    .did -ra mp3c 10 Standing by...
    .did -ra mp3c 7 00:00/00:00
    .did -ra mp3c 9 0 kbps / 0 Hz / 0MB
  }
  else { .did -ra mp3c 10 No song is playing... }
}

on *:dialog:mp3c:sclick:5:{ 
  if (!$did(mp3c,13,1)) { 
    .did -ra mp3c 10 No playlist!
    return
  }
  quickstop
  if (!$did(mp3c,13).sel) { .did -c mp3c 13 1 }
  .hadd -m lastplayedmp3 $mp3cf
  if ($did(mp3c,13,2)) .did -c mp3c 13 $calc($did(mp3c,13).sel + 1)
  spr
}

on *:dialog:mp3c:menu:55:{ 
  .did $iif($rcon(optsetting,apwl) == true,-u,-c) mp3c 55
  .echo -q $wcon(optsetting,apwl,$iif($rcon(optsetting,apwl) == true,false,true))
}

on *:dialog:mp3c:menu:50: { 
  .did $iif($rcon(optsetting,stpf) == true,-u,-c) mp3c 50
  .echo -q $wcon(optsetting,stpf,$iif($rcon(optsetting,stpf) == true,false,true))
}

on *:dialog:mp3c:menu:27:{ 
  var %tf = $sfile(C:,Select a file to add to playlist)
  if (%tf != $null) { 
    if ($right(%tf,4) != .mp3) { 
      .did -ra mp3c 10 Invalid file
      return
    }
    elseif ($read($+(",$scriptdirmp3cplaylist.txt,"),w,$+(*,%tf,*))) { 
      .did -ra mp3c 10 File already exists in playlist
      halt
    }
    else {
      .did -az mp3c 13 $remove($nopath(%tf),.mp3)
      .write $+(",$scriptdirmp3cplaylist.play,") %tf
      if ($rcon(optsetting,stpf) = true) { 
        .did -c mp3c 13 $didwm(mp3c,13,$+(*,$remove($nopath(%tf),.mp3),*))
        spr
      }
    }
  }
  else { .did -ra mp3c 10 No file selected to add }
}

on *:dialog:mp3c:menu:21:{ 
  if ($did(mp3c,13).sel) && ($isfile($+(",$scriptdirmp3cplaylist.play,"))) { 
    .write $+(-dl,$did(mp3c,13).sel) $+(",$scriptdirmp3cplaylist.play,")
    .did -d $dname 13 $did(mp3c,13).sel
  }
  else { .did -ra mp3c 10 No file selected for removal. }
}

on *:dialog:mp3c:menu:29:{ 
  var %td = $sdir(C:,Select a directory to add to playlist)
  if (%td != $null) { 
    var %x = 1
    while ($findfile(%td,*.mp3,%x)) { 
      .did -az mp3c 13 $remove($nopath($ifmatch),.mp3)
      .write $+(",$scriptdirmp3cplaylist.play,") $ifmatch
      inc %x
    }
  }
}

on *:dialog:mp3c:menu:31:dialog $iif($dialog(mp3c.vtog),-v,-m) mp3c.vtog mp3c.vtog

on *:dialog:mp3c:menu:33:{ 
  if ($did(mp3c,33).state == 1) { 
    .did -u mp3c 33 
    .dialog -sbp mp3c -1 -1 280 241
  }
  else { 
    .did -c mp3c 33
    .dialog -s mp3c -1 -1 $calc($dialog(mp3c).w - 5) $calc($dialog(mp3c).h + 10)
  }
}
on *:dialog:mp3c:menu:12:{
  var %ts = $sfile($mircdir*.play,Save Playlist, Save)
  if (!$gettok(%ts,2,46)) .set %mp3c.save $+(%ts,.,play)
  .set %mp3c.save %ts
  .copy -o $+(",$scriptdirmp3cplaylist.play,") $+(",%mp3c.save,")
  if (!$exists($+(",$scriptdirmp3cplaylist.play,"))) .did -ra mp3c 10 Empty playlist.
  .unset %mp3c.save
}

on *:dialog:mp3c:menu:14: {
  var %tmp = " $+ $sfile($mircdir*.play,Select a playlist to load, Open) $+ "
  if (%tmp != $null) && ($exists(%tmp)) {
    .copy $iif($rcon(optsetting,apwl) = true,-a,-o) %tmp $+(",$scriptdirmp3cplaylist.play,")
    var %x = 1
    .did -r mp3c 13
    while (%x <= $lines($+(",$scriptdirmp3cplaylist.play,"))) {
      .did -a mp3c 13 $nopath($read($+(",$scriptdirmp3cplaylist.play,"),%x))
      inc %x
    }
  }
  elseif (!%tmp) { .did -ra mp3c 10 No file selected to load. }
  elseif (!$exists(%tmp)) { .did -ra mp3c 10 Invalid file. }
}

on *:dialog:mp3c:sclick:36:{ 
  if ($did(mp3c,30).text) { 
    if ($didwm(mp3c,13,$+(*,$v1,*))) .did -c mp3c 13 $v1
    else .did -ra mp3c 30 ** No matches found **
  }
  else .did -ra mp3c 30 ** Nothing to search **
}

on *:dialog:mp3c:menu:16:{
  .did -r mp3c 13
  .remove $+(",$scriptdirmp3cplaylist.play,")
}

on *:dialog:mp3c:menu:38:{ 
  .did -u mp3c 39,40,48
  .did -c mp3c 38
  .echo -q $wcon(playsettings,end,continuous)
}

on *:dialog:mp3c:menu:39:{ 
  .did -u mp3c 38,40,48
  .did -c mp3c 39
  .echo -q $wcon(playsettings,end,repeat)
}

on *:dialog:mp3c:menu:40:{ 
  .did -u mp3c 38,39,48
  .did -c mp3c 40
  .echo -q $wcon(playsettings,end,shuffle)
}

on *:dialog:mp3c:menu:48:{ 
  .did -u mp3c 38-40
  .did -c mp3c 48
  .echo -q $wcon(playsettings,end,none)
}

on *:dialog:mp3c:menu:34:{ 
  var %tmp = $$input(Enter your spam message here. $&
    Available tags are &title &artist &bitrate &length &sample $&
    &size &c (equivilent to ctrl+k) &b (ctrl+b) &u (ctrl+u). You can also $&
    type ~disable to disable the spam.,eo,Enter spam message:)
  .echo -q $wcon(playsettings,spammsg,$iif(%tmp == ~disable,null,%tmp)) 
}

on *:dialog:mp3c:init:0:{ 
  if ($isfile($+(",$scriptdirmp3cplaylist.play,"))) { 
    var %x = 1
    while (%x <= $lines($+(",$scriptdirmp3cplaylist.play,"))) { 
      .did -az mp3c 13 $remove($nopath($read($+(",$scriptdirmp3cplaylist.play,"),%x)),.mp3)
      inc %x
    }
  }
  mp3.didcheck
}

on *:dialog:mp3c:scroll:11:{ 
  if ($insong) { 
    .set %insong.pos $did(mp3c,11).sel
    .splay -p seek $calc($did(mp3c,11).sel * 1000)
  }
}

on *:mp3end:{ 
  if ($did(mp3c,38).state == 1) { 
    .quickstop
    if ($did(mp3c,13).sel == $did(mp3c,13).lines) var %n = 1
    else var %n = $calc($did(mp3c,13).sel + 1)
    .did -c mp3c 13 %n
    spr
  }
  elseif ($did(mp3c,39).state == 1) spr
  elseif ($did(mp3c,40).state == 1) { 
    .quickstop
    .did -c mp3c 13 $r(1,$did(mp3c,13).lines)
    spr
  }
  else { .quickstop }
  .hadd -m lastplayedmp3 $mp3cf
}

dialog mp3c.vtog {
  title "Toggle volume"
  size -1 -1 298 66
  option pixels notheme
  text "Master", 1, 5 17 38 17
  scroll "", 2, 49 17 191 16, horizontal top range 0 100
  check "Mute", 5, 71 43 55 19, flat
  button "&Done", 6, 148 39 65 25, ok
  edit "", 7, 245 17 44 20
}

on *:dialog:mp3c.vtog:init:0:{ 
  .did -c mp3c.vtog 2 $round($calc($vol(master) * 100 / 65535),0)
  .did -a mp3c.vtog 7 $did($dname,2).sel $+ %
}

on *:dialog:mp3c.vtog:scroll:2:{ 
  .vol -v $calc(653.5 * $did($dname,2).sel) 
  .did -ra mp3c.vtog 7 $+($did($dname,2).sel,%)
}

on *:dialog:mp3c.vtog:sclick:5:{ 
  if ($vol(master).mute) .vol -vu2
  else .vol -vu1
}

Comments

Sign in to comment.
Priest   -  Jan 13, 2010

Btw, For any who dont know, NEVER try loading 30,000+ songs into an mp3 player on mirc. Its just a bad idea.

Edit: I just tried opening it again after it crashed me and guess what? it crashed my mirc without me even having to load anything. GG I'm not gonna try again ;)

 Respond  
The_Fuzzy_Wookie   -  Apr 02, 2008

honestly..
i tried to load a FILE.... and it only loaded song by song....
and the next prev buttons did not work!! AND it only worked twice fer me b4 it went totaly schizo!!
SO IDK... mb it is just my mirc.. or what ?????

 Respond  
Rebellious   -  Jan 05, 2008

Anyone got any more comments? =( Thinking about recoding this.

 Respond  
Rebellious   -  Jan 05, 2008

Sorry for the extremely late response here. Anyway, what error are you receiving? That way I can help you. Also, if you think something is wrong with the prev button, please read the introduction first. As I stated above, it will go back to the last song played, and NOT the song before the currently selected song in the list.

Hope you find the problem. :)

 Respond  
G13AoUsTiS   -  Dec 30, 2007

well something wrong when you hit \"stop, next , prev\"

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.