media player

By token on Sep 20, 2007

to open: either use the menu in a channel window or /aud.open, this will create a minizable desktop/mirc window with the mp3. to change directories: (for users with directories already) /aud.load destroydir -> /aud.load, (for new users) just open the dialog or type /aud.load. to enter the channels you do not want to display it in, change the %i variable to the desired value (remember to seperate the values by commas) to change the method of display (echo/msg(or descrive)) change the isoff to ison or vice versa. if you need to change the the type of msg, go the second value in the %i variable and change it to msg or describe.

;--------

FOR QUICK PLAY:

/quickmedia .play
/quickmedia .pause (type again to resume)
/quickmedia .stop
to edit if you want to enable the broadcast change the %i variable to off or on depending on your choice.

alias -l aud.ent { 
  if ($istok($1,mp3,46)) { return -p }
  if ($istok($1,wav,46)) { return -w }
  if ($istok($1,mid,46)) { return -m }
}
alias -l aud.seek { 
  if ($dialog(mplay)) && ($inmp3) { 
    ;nT0xIc8's scroll/seek bar
    did -c mplay 4 $round($calc($calc($insong.pos / $insong.length) * 100),0) 
    did -ra mplay 3 $+($gmt($round($calc($insong.pos / 1000),0),nn:ss),$chr(47),$gmt($round($calc($insong.length / 1000),0),nn:ss))
  } 
  else {
    if (!$dialog(mplay)) { 
      .timerpos off 
    } 
    if (!$inmp3) { halt }
  } 
}

alias aud.play { 
  var %int = $did(mplay,11).sel
  var %i = $did(mplay,11).seltext
  set -nu1 %temporary %int
  splay $aud.ent($nopath(%temporary)) $read(playlist.txt,%int)
  did -ra mplay 3 $gmt($round($calc($insong.pos / 1000),0),nn:ss)
  did -a mplay 2 $iif(!$sound($inmp3).artist,$remove(%i,.mp3,.wma,.mid),$sound($insong).title - $sound($insong).artist)
  .timerplay 0 1 aud.seek
}

alias aud.stop { 
  .timerplay off 
  splay -p stop
  splay -w stop
  splay -m stop
  did -ra mplay 3 00:00/00:00
  did -ra mplay 2 << no song is currently playing >>
  if (%aud.pause) { unset %aud.pause }
}

alias aud.pause {
  if ($inmp3) { 
    if (!%aud.pause) { set %aud.pause 1 }
    if (%aud.pause = 1) {  
      .timerplay -p 
      splay pause
      did -ra mplay 2 << song is currently paused >>
      inc %aud.pause 1
      halt
    }
    if (%aud.pause = 2) { inc %aud.pause 1 }
    if (%aud.pause = 3) { 
      .timerplay -r 
      splay resume
      did -ra mplay 2 $iif(!$sound($inmp3).artist,$remove($did($dname,11).seltext,.mp3,.wma,.mid),$sound($insong).title - $sound($insong).artist)
      unset %aud.pause
      halt
    }
  }
}

alias aud.load { 
  var %tmpdir $sdir(C:,Music Files)
  if ($dialog(mplay)) did -r mplay 11
  var %x 1 
  :start
  if (%getnum|mp3 = 1) { inc %getnum|mp3 }
  while ($findfile(%tmpdir,*.mp3,%x)) {
    if ($dialog(mplay)) { did -a mplay 11 $nopath($findfile(%tmpdir,*.mp3,%x)) }
    write playlist.txt $findfile(%tmpdir,*.mp3,%x)
    inc %x
  }
  var %x 1  
  while ($findfile(%tmpdir,*.wav,%x)) {
    if ($dialog(mplay)) { did -a mplay 11 $nopath($findfile(%tmpdir,*.wav,%x)) }
    write playlist.txt $findfile(%tmpdir,*.wav,%x)
    inc %x
  }
  var %x 1 
  while ($findfile(%tmpdir,*.midi,%x)) {
    if ($dialog(mplay)) { did -a mplay 11 $nopath($findfile(%tmpdir,*.midi,%x)) }
    write playlist.txt  $findfile(%tmpdir,*.midi,%x)
    inc %x
  }
  halt
  if ($1 = destroydir) { 
    remove playlist.txt
    unset %getnum|mp3
    goto start
  }
  if ($1 = remfile) { 
    if ($2-) {
      if ($read(playlist.txt,$nopath($1)) { write -dl $v1 }
    }
  }
}

dialog mplay {
  title "media player"
  size -1 -1 159 116
  option dbu
  box "", 1, 4 2 150 33
  text "", 2, 8 11 137 8
  text "", 3, 8 23 38 8
  scroll "", 4, 51 23 95 8, range 0 100 horizontal bottom
  button "<<", 5, 17 97 23 12
  button ">", 6, 40 97 23 12
  button "||", 7, 63 97 23 12
  button "[ ]", 8, 86 97 23 12
  button ">>", 9, 109 97 23 12
  box "Playlist", 10, 6 36 139 58
  list 11, 10 43 130 46, size
}

on *:dialog:mplay:init:0:{  
  var %x 1
  inc %getnum|mp3
  if (%getnum|mp3 iswm 1) { aud.load }
  else {
    while ($read(playlist.txt,%x)) { 
      did -a $dname 11 $nopath($v1)
      inc %x
    }
  }
}
on *:dialog:mplay:sclick:6:{ 
  aud.play
}
on *:dialog:mplay:sclick:5:{ 
  did -c $dname 11 $calc($did($dname,11).sel - 1)
  aud.play
}
on *:dialog:mplay:sclick:9:{ 
  did -c $dname 11 $calc($did($dname,11).sel + 1)
  aud.play
}
on *:dialog:mplay:sclick:8:{ 
  aud.stop
}
on *:dialog:mplay:sclick:7:{ 
  aud.pause
}
;nT0xIc8's scroll in dialog format
on *:dialog:mplay:scroll:4:{
  if ($devent == scroll) { 
    if ($did == 4) { 
      if ($insong == $true) { 
        var %t $round($calc($did(mplay,4).sel / 22000 * $insong.length),0) 
        splay seek $calc((%t + $did(mplay,4).sel) * 200) 
      } 
    } 
  } 
} 

on *:dialog:mplay:close:{ 
  aud.stop 
}

alias aud.ad { 
  var %f = @title - @duration
  var %c = channels,not,allowed,to,use
  var %i = ison,msg
  if ($insong) {
    if ($gettok(%i,1,44) = isoff) { 
      echo -a $replace($gettok(%f,1-,44),@duration,$gmt($round($calc($insong.length / 1000)),nn:ss),@title,$iif(!$sound($insong.fname).artist,$remove($replace($nopath($insong.fname),_,$chr(32)),.mp3),$sound($insong.fname).title - $sound($insong.fname).artist))
    }
    elseif ($gettok(%i,1,44) = ison) { 
      var %c = 1
      while ($chan(%c)) { 
        if (!$istok(%i, $chan(%c),44)) { $+(/,$gettok(%i,2,44)) $chan(%c) $replace($gettok(%f,1-,44),@duration,$gmt($round($calc($insong.length / 1000)),nn:ss),@title,$iif(!$sound($insong.fname).artist,$remove($replace($nopath($insong.fname),_,$chr(32)),.mp3),$sound($insong.fname).title - $sound($insong.fname).artist)) }
        inc %c
      }
    }
  }
}

;----------------- QUICK ACCESS PLAY -----------------

alias quickmedia { 
  if ($1) { 
    if ($v1 = .play) { 
      var %i on
      var %s = $$sfile($mircdir, choose a file to play:) 
      splay $aud.ent(%s) %s
      if (%i = on) aud.ad
    }
    if ($v1 = .pause) { 
      if ($insong) { 
        if (!%tmpo) {
          splay pause
          set %tmpo 1
          halt
        }
        elseif (%tmpo) { splay resume | unset %tmpo }
      }
    }
    if ($v1 = .stop) { 
      if ($insong) { splay stop }
    }
  }
}

;---------------- OTHER ------------------

menu channel { 
  mp3
  .open:aud.open
  .advertise:aud.ad
}

alias aud.open { if (!$dialog(mplay)) { dialog -mdo mplay mplay }

Comments

Sign in to comment.
Mudkipz   -  Jan 20, 2008

how would i add more than one song at a time?

 Respond  
RubixCube   -  Sep 30, 2007

Really nice media player token good work. There is just a minute bug that I found. In your aud.load alias, it doesn\'t check if the playlist.txt is already made. As a result, it adds on to the playlist.txt when changing your directory. Here is the fixed code:

alias aud.load { 
  if ($isfile(playlist.txt)) write -c playlist.txt
  var %tmpdir $sdir(C:,Music Files)
  if ($dialog(mplay)) did -r mplay 11
  var %x 1 
  :start
  if (%getnum|mp3 = 1) { inc %getnum|mp3 }
  while ($findfile(%tmpdir,*.mp3,%x)) {
    if ($dialog(mplay)) { did -a mplay 11 $nopath($findfile(%tmpdir,*.mp3,%x)) }
    write playlist.txt $findfile(%tmpdir,*.mp3,%x)
    inc %x
  }
  var %x 1  
  while ($findfile(%tmpdir,*.wav,%x)) {
    if ($dialog(mplay)) { did -a mplay 11 $nopath($findfile(%tmpdir,*.wav,%x)) }
    write playlist.txt $findfile(%tmpdir,*.wav,%x)
    inc %x
  }
  var %x 1 
  while ($findfile(%tmpdir,*.midi,%x)) {
    if ($dialog(mplay)) { did -a mplay 11 $nopath($findfile(%tmpdir,*.midi,%x)) }
    write playlist.txt  $findfile(%tmpdir,*.midi,%x)
    inc %x
  }
  halt
  if ($1 = destroydir) { 
    remove playlist.txt
    unset %getnum|mp3
    goto start
  }
  if ($1 = remfile) { 
    if ($2-) {
      if ($read(playlist.txt,$nopath($1)) { write -dl $v1 }
    }
  }
}
  • Really simple edit.

It would be great if you can add an add file feature as well. I have a large directory of songs. Perhaps a:

var %s = $sfile(C:\\,Choose a song to add)
write playlist.txt %s
 Respond  
token   -  Sep 25, 2007

Update: added a quick media option and edited a few bugs

 Respond  
Zsadist   -  Sep 24, 2007

Very nice. Though I found I hated hash tables, you seemed to have done well with this one. I work more with ini\'s but still, nice job :3

 Respond  
token   -  Sep 23, 2007

stargazer989, was the dialog open when you typed this? i probably am going to add a quick use part so that you don\'t recieve that error. but the dialog should be open for the commands atm.

Akishoot, thank you. ^^

 Respond  
Akishoot   -  Sep 22, 2007

Nice work on this one, token. The use of the horizontal scrollbar like that is truly unique. :3 I like it :D

 Respond  
stargazer989   -  Sep 22, 2007

ok i\'m getting \" * Invalid parameters: $did (line 21, mp3system) \" when i type /aud.play
any suggestion this is the only error so far ?

 Respond  
Kyousoukyoku   -  Sep 22, 2007

Nice! Looks a lot better now. :)

 Respond  
token   -  Sep 22, 2007

alright kyou, i have made the updates. thank you so much for the feedback.

 Respond  
Kyousoukyoku   -  Sep 22, 2007

Couple things. 1) Where is the aud.open command? I can\'t even open the dialog. :( 2) Your intro isn\'t updated. ;) 3) I would add a bit more functions. Perhaps an add file and remove file ability as SilentExile has stated and everything can only be set through one time. What if I wanted to add channels or change the directory? Other then that, I haven\'t performed extensive testing so I can\'t say anything else. Nice job on the coding though. =)

 Respond  
token   -  Sep 22, 2007

performed extreme updates. made in into a neast dialog that may require a bit of setup at first. and at Kyousoukyoku, that would be cool. i\'ll try and figure out a way to include that.

 Respond  
Kyousoukyoku   -  Sep 22, 2007

Pretty good, but I think it would be cool if you added a way to use multiple playlists. I would either make it a dialog or use window commands if that is what you are trying to do, it just makes it easier to utilize.

 Respond  
token   -  Sep 21, 2007

thanks SilentExile, i am currently trying to find a way to manipulate everything through a new window. this window will include all of the features your are asking. =)

 Respond  
SilentExile   -  Sep 21, 2007

The thing I like about this snippet is that it doesn\'t require a dialog to function. It\'s simple to control and manipulate. I would add a little more functionality to this snippet. Perhaps an an add
file/remove file option and a previous & next function? Maybe more info on the disp. message? Nice job for your first time with hash tables.

 Respond  
token   -  Sep 20, 2007

completely reworked everything. it now includes a bit more compatibility then the last. hope you enjoy the update. =)

 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.