Audio Player

By tank59 on Jan 20, 2006

Okay, this is a audio player that uses hash tables. I originally got the idea from Del_Felesif's mp3 player. This is all mIRC, so it's going to have limitations, and obviously, I have limitations :D. I wasn't able to test it really well, so any bugs let me know and I'll try to fix them. It's pretty self explanitory. A few things I should mention so people don't ask, are:

  1. I know I used a lot of dialog events, but I didn't want to have to deal with a bunch of if/elseif/else statements. It's just the way I did it.
  2. In order to use the spam message, you need to first set one. Go to Edit -> Spam Message -> Edit Message. Then you have two options, you can manually display it in the active channel by typing '/jam' or you can select the Spam Message option in the Edit menu.
  3. The search thing at the bottom is simply to search the current song list. I made that because, if you're like me, I have 400 songs in my playlist, and sometimes I can't find one I'm looking for.
  4. The id3 tag editor is used for the spam message. I borrowed some code from PR|MuS's MiniID3 Editor. It seemed to work okay. For those who don't know what id3 tags are, they're the info that is in your song when you use the spam. If no info displays, and the file is an mp3, then you probably need to update your id3 tags. Yes, you'll only be able to use the id3 tags with mp3's due to mIRC's restrictions. I've put a custom spam message simply using the filename for non mp3's.
  5. If you want your playlist saved, you need to go to File -> Save List. I didn't add any load or exit events to save the hash, so you'll need to do that yourself if you like your playlist.

That's about it. Like I said, if you have any bugs or questions let me know. I tried to find every possible bug, but I'm not perfect. Enjoy.
Usage: /aud

; audio player v.2.00 by tank59
; email: jalopenobologna@gmail.com
; Please report any and all bugs
; Usage: /aud
;
; Enjoy!
alias aud dialog -md aud aud
dialog aud {
  title "Audio Player"
  size -1 -1 157 155
  option dbu
  list 14, 6 7 145 67, size
  box "Song List", 15, 3 0 151 78
  button "Play", 13, 3 80 27 12, flat
  button "Stop", 16, 34 80 27 12, flat
  button "< Prev", 17, 65 80 27 12, flat
  button "Next >", 18, 96 80 27 12, flat
  button "Pause", 19, 127 80 27 12, flat
  edit "No Song Is Playing", 20, 2 96 112 10, read
  scroll "", 22, 3 109 151 8, range 100 horizontal bottom
  box "Volume Control", 23, 3 119 151 21
  button "+", 24, 11 127 10 10
  button "-", 25, 63 127 10 10
  text "Volume Up", 26, 24 128 30 8
  text "Volume Down", 27, 76 128 35 8
  check "Mute", 28, 120 127 26 10
  text "00:00", 29, 116 97 14 8
  text "/", 30, 132 97 4 8
  text "00:00", 31, 137 97 15 8
  edit "", 21, 3 143 87 10
  button "Search", 32, 93 143 27 10, ok flat
  link "hawkee.com", 33, 124 146 32 8
  menu "File", 1
  item "Add Dir", 2, 1
  item "Add File", 3, 1
  item "Remove File", 4, 1
  item "Clear List", 5, 1
  item "Save List", 6, 1
  menu "Edit", 7
  menu "Spam Message", 9, 7
  item "Spam Message", 34, 9
  item "Edit Message", 35, 9
  item "ID3 Tags", 10, 7
  menu "Options", 8
  item "Repeat", 11, 8
  item "Shuffle", 12, 8
}
on *:dialog:aud:init:0:{
  if ($isfile(tsong.hsh)) {
    if ($hget(tsong)) { 
      hload tsong tsong.hsh     
    }
    else {
      hmake tsong 100 
      hload tsong tsong.hsh
    }  
  } 
  var %x = 1
  while (%x <= $hget(tsong,0).item) {
    did -a aud 14 $nopath($hget(tsong,%x))
    inc %x  
  }
  if ($didwm(aud,14,*$song $artist $length*)) {
    did -d aud 14 $v1
  }
  elseif ($hget(tsong,spam)) {  
    if ($did(aud,14).lines == $hget(tsong,0).item) {
      did -d aud 14 $did(aud,14).lines
    }
  }
}
on *:dialog:aud:menu:2:{
  var %dir $sdir(C:,Music Files)
  did -r aud 14  
  var %x 1
  while ($findfile(%dir,*.mp3,%x) != $null ) {
    did -a aud 14 $nopath($findfile(%dir,*.mp3,%x))
    hadd -m tsong %x $findfile(%dir,*.mp3,%x)
    inc %x
  }
  var %x 1  
  while ($findfile(%dir,*.wav,%x) != $null ) {
    did -a aud 14 $nopath($findfile(%dir,*.wav,%x))
    hadd -m tsong %x $findfile(%dir,*.wav,%x)
    inc %x
  }
  var %x 1 
  while ($findfile(%dir,*.midi,%x) != $null ) {
    did -a aud 14 $nopath($findfile(%dir,*.midi,%x))
    hadd -m tsong %x $findfile(%dir,*.midi,%x)
    inc %x
  }
}
on *:dialog:aud:menu:3:{
  var %file $sfile(C:,Music Files)
  did -a aud 14 $nopath(%file)
  hadd -m tsong $hget(tsong,0).item %file
}
on *:dialog:aud:menu:4:{
  if ($did(aud,14).sel == $null) {
    did -ra aud 20 Error: No Song Selected to Remove
    .timermp3status 1 3 did -ra aud 20 No Song Is Playing
  }
  else {
    hdel -w tsong $hfind(tsong,$+(*,$did(aud,14).seltext,*),w,1).data
    did -d aud 14 $did(aud,14).sel
  }
}
on *:dialog:aud:menu:5:{
  did -r aud 14 
  hfree tsong
  .remove tsong.hsh
}
on *:dialog:aud:menu:6:{
  hsave -o tsong tsong.hsh
  echo -s Play List Saved.
}
on *:dialog:aud:menu:10: dialog -m id3 id3
on *:dialog:aud:menu:11:{
  if ($did(12).state == 1) {
    did -u aud 12 
    $iif($did(11).state == 1,did -u $dname 11,did -c $dname 11)
  }
  else $iif($did(11).state == 1,did -u $dname 11,did -c $dname 11)
}
on *:dialog:aud:menu:12:{
  if ($did(11).state == 1) {
    did -u aud 11 
    $iif($did(12).state == 1,did -u $dname 12,did -c $dname 12)
  }
  else $iif($did(12).state == 1,did -u $dname 12,did -c $dname 12)
}
on *:dialog:aud:menu:34: $iif($did(34).state == 1,did -u $dname 34,did -c $dname 34)
on *:dialog:aud:menu:35: dialog -m spam spam
on *:dialog:aud:close:0:{
  splay stop 
  .timerpos off
}
on *:dialog:aud:sclick:13: audplay 
on *:dialog:aud:sclick:16: stop
on *:dialog:aud:sclick:17: prev
on *:dialog:aud:sclick:18: next
on *:dialog:aud:sclick:19:{ 
  if ($insong == $true) && (!$insong.pause) {
    splay pause  
    did -ra aud 19 Resume
  } 
  elseif ($insong.pause) {
    splay resume    
    did -ra aud 19 Pause  
  } 
}
on *:dialog:aud:sclick:24: {
  if ($did(28).state == 1) {
    did -u aud 28
    vol -pu2
    vol -v $calc($vol(master) + 2000) 
  }
  else {
    vol -v $calc($vol(master) + 2000)
  }
}
on *:dialog:aud:sclick:25: {
  if ($did(28).state == 1) {
    did -u aud 28
    vol -pu2
    vol -v $calc($vol(master) - 2000) 
  }
  else {
    vol -v $calc($vol(master) - 2000)
  }
}
on *:dialog:aud:sclick:28: $iif($did(28).state == 1,vol -pu1,vol -pu2)
on *:dialog:aud:dclick:14: audplay  
on *:dialog:aud:sclick:32:{
  did -c aud 14 $didwm(aud,14,$+(*,$did(aud,21),*),1) 
  did -r aud 21  
  halt
}
on *:dialog:aud:sclick:33: run http://www.hawkee.com/
; Below is part of nTOxIc8's
; mp3player seek/scroll bar
on *:dialog:aud:scroll:22:{
  if ($devent == scroll) { 
    if ($did == 22) { 
      if ($insong == $true) { 
        var %t $round($calc($did(aud,22).sel / 22000 * $insong.length),0) 
        splay seek $calc((%t + $did(aud,22).sel) * 200) 
      } 
    } 
  } 
} 
on *:mp3end: next
on *:waveend: next
on *:midiend: next
alias audplay {
  if ($insong.pause == $true) { 
    did -ra aud 19 Pause 
  }
  if ($did(aud,14).lines == 0) {
    did -ra aud 20 No Playlist
    halt
  }
  elseif ($did(aud,14).sel == $null) {
    did -ra aud 20 No Song Selected
    halt
  }
  else {    
    if ($sound($hget(tsong,$hfind(tsong,$+(*,$did(aud,14).seltext,*),1,w).data)).title != $null) {
      did -ra aud 20 Playing: $sound($hget(tsong,$hfind(tsong,$+(*,$did(aud,14).seltext,*),1,w).data)).title
      did -ra aud 31 $asctime($calc($sound($hget(tsong,$hfind(tsong,$+(*,$did(aud,14).seltext,*),1,w).data)).length / 1000 ),nn:ss)    
      .timerpos 0 1 pos.seek  
      splay $hget(tsong,$hfind(tsong,$+(*,$did(aud,14).seltext,*),1,w).data)
    }
    else {
      did -ra aud 20 Playing: $did(aud,14).seltext
      did -ra aud 31 $asctime($calc($sound($hget(tsong,$hfind(tsong,$+(*,$did(aud,14).seltext,*),1,w).data)).length / 1000 ),nn:ss)    
      .timerpos 0 1 pos.seek    
      splay $hget(tsong,$hfind(tsong,$+(*,$did(aud,14).seltext,*),1,w).data)
    }
  }
  if ($did(aud,34).state == 1) {  
    if ($hget(tsong,spam)) {  
      if ($sound($hget(tsong,$hfind(tsong,$+(*,$did(aud,14).seltext,*),1,w).data)).title == $null) && ($did(aud,34).state == 1) msg $active Jamming to $did(aud,14).seltext
      else $iif($did(aud,34).state == 1,$($+($hget(tsong,spam)),2),return)  
    }
  }
}
alias stop {
  splay stop
  .timerpos off
  did -ra aud 20 No Song Is Playing
  did -ra aud 31 00:00
  did -ra aud 29 00:00  
}
alias prev {
  splay stop
  .timerpos off
  if ($did(aud,12).state == 1) {
    if ($hget(tsong,spam)) {
      did -c aud 14 $r(1,$calc($hget(tsong,0).item - 1))   
      audplay  
    }
    else {
      did -c aud 14 $r(1,$hget(tsong,0).item)
      audplay
    }
  }
  elseif ($did(aud,11).state == 1) { audplay }
  else {
    did -c aud 14 $calc($did(aud,14).sel - 1) 
    audplay  
  }
}
alias next {
  splay stop
  .timerpos off
  if ($did(aud,12).state == 1) {
    if ($hget(tsong,spam)) {
      did -c aud 14 $r(1,$calc($hget(tsong,0).item - 1))   
      audplay  
    }
    else {
      did -c aud 14 $r(1,$hget(tsong,0).item)
      audplay
    }
  }
  elseif ($did(aud,11).state == 1) { audplay }
  elseif ($did(aud,14).sel == $did(aud,14).lines) && ($did(aud,11).state == 0) && ($did(aud,12).state == 0) {
    did -c aud 14 1  
    audplay
  }
  else {
    did -c aud 14 $calc($did(aud,14).sel + 1) 
    audplay  
  }
} 
; Below is part of nTOxIc8's
; mp3player seek/scroll bar
alias -l pos.seek { 
  if ($dialog(aud) != $null) && ($inmp3 == $true) { 
    did -c aud 22 $round($calc($calc($insong.pos / $insong.length) * 100),0) 
    ;the below line was basically written by the good ImthePariah    
    did -ra aud 29 $+($gettok($duration($calc($insong.pos / 1000),3),2-,58),/,$gettok($duration($calc($insong.length / 1000),3),2-,58))
  } 
  elseif ($dialog(aud) == $null) { 
    .timerpos off 
  } 
} 
alias length {
  return $asctime($calc($sound($hget(tsong,$hfind(tsong,$+(*,$did(aud,14).seltext,*),1,w).data)).length / 1000 ),nn:ss)
}
alias artist {
  return $sound($hget(tsong,$hfind(tsong,$+(*,$did(aud,14).seltext,*),1,w).data)).artist
}
alias song {
  return $sound($hget(tsong,$hfind(tsong,$+(*,$did(aud,14).seltext,*),1,w).data)).title
}
alias bit {
  return $sound($hget(tsong,$hfind(tsong,$+(*,$did(aud,14).seltext,*),1,w).data)).bitrate
}
alias jam {
  if ($hget(tsong,spam)) {
    if ($sound($hget(tsong,$hfind(tsong,$+(*,$did(aud,14).seltext,*),1,w).data)).title == $null) msg $active Jamming to $did(aud,14).seltext
    else $($+($hget(tsong,spam)),2)
  }
  else echo -a No Spam Message set.  
}
dialog spam {
  title "Spam Message"
  size -1 -1 147 82
  option dbu
  radio "Message all channels", 1, 2 3 63 10, 
  radio "Describe all channels", 2, 75 3 64 10, group
  radio "Message active channels", 3, 2 16 72 10, group
  radio "Describe active channels", 4, 75 16 71 10, group
  text "Select one of the above boxes and fill in the message that you would like to use for your spam message. You can use the following identifiers to return song info. $length = Song length $artist = Artist $song = Title $bit = Bitrate", 5, 1 27 145 28
  edit "", 6, 25 57 115 10, autohs
  text "Message:", 7, 1 58 24 8
  button "Set", 8, 7 70 25 10, ok flat
  button "Cancel", 9, 34 70 25 10, cancel flat
} 
on *:dialog:spam:init:0:{
  if ($gettok($hget(tsong,spam),1,32) == msg) did -c spam 3
  if ($gettok($hget(tsong,spam),1,32) == describe) did -c spam 4
  if ($gettok($hget(tsong,spam),1,32) == amsg) did -c spam 1
  if ($gettok($hget(tsong,spam),1,32) == ame) did -c spam 2  
  if ($gettok($hget(tsong,spam),1,32) == msg) || ($gettok($hget(tsong,spam),1,32) == describe) {
    $iif($hget(tsong,spam),did -a spam 6 $gettok($hget(tsong,spam),3-,32),return)
  }    
  else {
    $iif($hget(tsong,spam),did -a spam 6 $gettok($hget(tsong,spam),2-,32),return)
  }
}
on *:dialog:spam:sclick:1: did -u spam 2,3,4
on *:dialog:spam:sclick:2: did -u spam 1,3,4
on *:dialog:spam:sclick:3: did -u spam 1,2,4
on *:dialog:spam:sclick:4: did -u spam 1,2,3
on *:dialog:spam:sclick:8:{
  if ($did(spam,1).state == 0) && ($did(spam,2).state == 0) && ($did(spam,3).state == 0) && ($did(spam,4).state == 0) {
    did -ra spam 6 You need to check a message type.
    halt
  }
  else {
    if ($did(spam,1).state == 1) hadd -m tsong Spam amsg $did(spam,6)
    elseif ($did(spam,2).state == 1) hadd -m tsong Spam ame $did(spam,6)
    elseif ($did(spam,3).state == 1) hadd -m tsong Spam msg $eval($active,0) $did(spam,6)
    elseif ($did(spam,4).state == 1) hadd -m tsong Spam describe $eval($active,0) $did(spam,6)
  }
}
dialog id3 {
  title "Id3 Changer"
  size -1 -1 88 90
  option dbu
  list 1, 1 0 86 52, size
  text "Title:", 2, 2 54 13 8
  text "Artist:", 3, 2 65 14 8
  edit "", 4, 16 53 66 10, autohs
  edit "", 5, 16 64 66 10, autohs
  button "Save", 6, 3 76 22 12, flat
  button "Close", 7, 33 76 22 12, flat ok
  button "Cancel", 8, 63 76 22 12, flat cancel
}
on *:dialog:id3:init:0:{
  var %x = 1
  while (%x <= $hget(tsong,0).item) {
    did -a id3 1 $nopath($hget(tsong,%x))
    inc %x  
  }
  if ($didwm(aud,14,*$song $artist $length*)) {
    did -d id3 1 $v1
  }
  elseif ($hget(tsong,spam)) {  
    if ($did(id3,1).lines == $hget(tsong,0).item) {
      did -d id3 1 $did(id3,1).lines
    }
  }
}
on *:dialog:id3:dclick:1:{
  set %song $hget(tsong,$hfind(tsong,$+(*,$did(id3,1).seltext,*),1,w).data)
  did -r id3 5,4  
  if ($sound(%song).artist) did -a id3 5 $ifmatch
  if ($sound(%song).title) did -a id3 4 $ifmatch
}
on *:dialog:id3:sclick:6:{
  $EDIT($shortfn(%song),1,4)
  $EDIT($shortfn(%song),2,5)
}
; Following piece of code from PR|MuS's MiniID3 Editor
; Seeing as I know nothing about Binvars XP
; http://www.mircscripts.org/showdoc.php?type=code&id=1186 
; Author: PR|MuS
; Email: Shredplayer@email.com
alias -l EDIT {
  bread $1 $B_CALC($1,128) 3 &tag
  if ($bvar(&tag,1-3).text != TAG) {
    bwrite $1 $B_CALC($1,128) 3 TAG
    bset &fill 125 0
    bwrite $1 $B_CALC($1,125) 124 &fill
    bunset &fill
  }
  if ($did(id3,4)) || ($did(id3,5)) {  
    bset &val $N_BYTE($2) $did(id3,$3)          
    bwrite $1 $S_BYTE($1,$2) $N_BYTE($2) &val
    $iif($2 < 6,.bwrite $1 $S_BYTE($1,$2) $N_BYTE($2) $did(id3,$3))
  }    
  else {
    bset &val 30 $asc($chr(32))
    bwrite $1 $S_BYTE($1,$2) $N_BYTE($2) &val
  }
  bunset &val
}
alias -l B_CALC return $calc($file($1).size - $2)
alias -l N_BYTE return $gettok(30 30 30 4 30 1,$1,32)
alias -l S_BYTE return $calc($file($1).size - $gettok(125 95 65 35 31 1,$2,32))

Comments

Sign in to comment.
guest598594   -  Dec 17, 2007

i found one minor error, if you click pause in the middle of a song and then press play, the pause button stays on resume and its already resumed

also, i suggest that you deselect mute when you raise the volume, but other than that, it worked fine

 Respond  
Dizzlenub   -  Jul 12, 2007

Oh, and sorry for double post, but... I can\'t seem to edit mah message. >_>

 Respond  
Dizzlenub   -  Jul 12, 2007

Any way to hook this up with LimeWire/FrostWire?

 Respond  
DarkRaviel   -  May 16, 2007

nice work but...
i get this message in my status:

  • Invalid parameters: $did (line 237, audio_player.mrc)
    where line 237 is: if ($did(aud,12).state == 1) {
    any idea of how i can avoid this problem ..
 Respond  
Scakk   -  Mar 11, 2007

Sorry for the double post.

I fixed this part

|Also I am not sure if it is possible is there a way to have it play only in certain channels instead of all the channel you are in. Ex: #Channel1,#Channel2 but not in #Channel3,#Channel4|

I still cannot fix the ID3 changer.

 Respond  
Scakk   -  Mar 11, 2007

When I try to use the ID3 changer I get

  • /bread: insufficient parameters (line 374, script1.ini)

as an error message.

Any ideas how to adjust that or fix it.

Also I am not sure if it is possible is there a way to have it play only in certain channels instead of all the channel you are in. Ex: #Channel1,#Channel2 but not in #Channel3,#Channel4

 Respond  
TheOnlyOne   -  Dec 28, 2006

Dude this is awesom :-) keep the god work :D And if you have an idea how to do it I suggest u try to do a movie player...That\'s what I really need...

 Respond  
MarsGirl   -  Aug 06, 2006

thnx mooooooooooot

 Respond  
Zachery   -  Jan 21, 2006

*tip do not add 1919 songs at ONE time >:(

 Respond  
DarthReven   -  Jan 21, 2006

Looks pretty solid nice work

 Respond  
tank59   -  Jan 21, 2006

Updated** Fixed a saving playlist issue.
Thanks for all the comments guys.

 Respond  
Bankotsu   -  Jan 21, 2006

Sch.. \'Kay then.

 Respond  
XpLoiTeR   -  Jan 21, 2006

lol cheerup man was a joke

 Respond  
Bankotsu   -  Jan 21, 2006

\"dont be overjelous cause i am picky about dialog aligment and design\" Dude, Why would someone be overjealous just because you\'re picky over dialog alignment?? :[

 Respond  
RoninWarrior   -  Jan 21, 2006

@XpLoiTeR yes use the mp3 player tank and or yonix has made and posted on this site and you will see really nice dialog aligment and dont be overjelous cause i am picky about dialog aligment and design and in any case dialog design and aligment can make or break any snippet and addon regardless of how great it works if it looks like poop most people probally wont use it that is all my opinion though

 Respond  
nobody   -  Jan 21, 2006

Good job, man.

 Respond  
Yoinx   -  Jan 21, 2006

lol, I made mine back when I kept seeing all these \"select a file to play it\" mp3 player snippets.

Nice work tank.

 Respond  
XpLoiTeR   -  Jan 21, 2006

RonninWarrior do u like the dialog alignment? :D

 Respond  
RoninWarrior   -  Jan 21, 2006

Tank59 i just have to say very nice mp3 player i myself am not big into the .dll thingy and this is deffintly one of the 2 best music players on this site now by far hands down the only thing i seen that was a bit off was the id3 tag editor could be a bit bigger/more readable( a bit wider in size) this is a very good job it loaded over 580 mp3 on my pc in just about 3 seconds i would say and i like that smoothe layout keep up the good work this is a true exsample of great codeing here for sure .

Yonix watch out your mp3 player has a competitor now :}

 Respond  
XpLoiTeR   -  Jan 21, 2006
  • /splay: unable to play \'E:\english songs\Agathodaimon\Agathodaimon - Chapter III - 07 - Sacred Divinity.mp3\' (line 172, script3.ini)
    i get that errror beside ive few notes:
    the design is pretty good but will be better if u used mdx for a trackbar instead of that scroller and for the play prev so on...
    on the other hands i think its better to add a option to let the user choose the channels which he wants the mp3 to spam to separated by a character..lets say ! so it will be like #channel1!#channel2!#channel3
    in addition to that i recommend adding more tags than artist , length , title...maybe if u added bitrate,size will be better...the mp3 has a good feature whici is editing and savin id3 tags thats great n so handy it can be submitted as a standalone snippet too...finally idlike to say its vry nice mp3player with a nice interfece and features just need lil modifications and i think it will be 8.5 or 9.0 ... GJ tanky :)
 Respond  
tank59   -  Jan 20, 2006

Thanks, Kutsum. Kazuma, you need to put the info in using the id3 Tag\'s editor.

 Respond  
`Kazuma   -  Jan 20, 2006

Nope, I dont have any other Mp3 Script. Oh, whoops. Yes it is an Mp3 and no the info isn\'t.

 Respond  
KuTsuM   -  Jan 20, 2006

Very nice for mIRC, tank59. Have to credit you with that. Good job ;)

 Respond  
tank59   -  Jan 20, 2006

First of all, alias aud doesn\'t need the brackets. Second, is the file an mp3, is the info there, and do you have another mp3 script that could be interferring with it?

 Respond  
`Kazuma   -  Jan 20, 2006

Im also geting this error, it wont show the info:
[23:48] ~Bankotsu MP3: Track 1 -
[23:48]
~Bankotsu MP3: Run It (Remix)-Chris Brown fea -

 Respond  
`Kazuma   -  Jan 20, 2006

you forgot the brackets;
alias aud dialog -md aud aud
should be

alias aud { dialog -md aud aud }

 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.