TopaZ music player

By TopaZ_ on Nov 10, 2007

Snippet that can play your mp3s. You can locate file names in your playlist (for those who are lazy like I am), add directories, add files, remove files, manipulate volume, and shuffle+repeat mp3s. Will be adding more soon, this is just a beta version. Hope you guys like this.

/topazmp3 [desktop] to open [desktop], obviously, opens the player on the desktop too.

alias topazmp3 if (!$dialog(tmp3)) dialog $iif($1 = desktop,-md,-m) tmp3 tmp3 | else dialog -v tmp3 
dialog tmp3 {
  title "TopaZ mp3player"
  size -1 -1 281 151
  option pixels
  list 2, 3 6 228 113, hsbar vsbar size 
  edit "", 11, 2 122 273 20, read autohs
  button "<<", 5, 231 6 45 25, flat
  button "|>", 6, 231 30 45 25, flat
  button "", 7, 231 54 45 25, flat
  button ">>", 8, 231 78 45 25, flat
  menu "File/Other options", 1
  item "Add file to playlist", 3, 1
  item "Remove selected from playlist", 4, 1
  item "Add directory...",13, 1
  item "Clear...",14,1
  item "Exit mp3", 12, 1
  menu "End options",15
  item "Repeat",16,15
  item "Shuffle",17,15
  menu "Extras", 18 
  item "Locate an mp3...",19, 18
  item "Volume...",20,18
  item "Play a random mp3...",21,18
}

on *:dialog:tmp3:init:0:{ 
  var %x = 1
  while (%x <= $lines($+(",$scriptdirplaylist.txt,"))) { 
    did -az $dname 2 $remove($nopath($read($+(",$scriptdirplaylist.txt,"),%x)),.mp3)
    inc %x
  }
}
on *:dialog:tmp3:close:0:if (%tmp3.temp.pause) unset %tmp3.temp.pause
on *:dialog:tmp3:menu:*:{ 
  if ($did = 3) { 
    var %selfile = $sfile($mircdirsounds,Select file to add) 
    write $+(",$scriptdirplaylist.txt,") %selfile
    did -az $dname 2  $remove($nopath($v1),.mp3)
  }
  if ($did = 4) { 
    if ($read($+(",$scriptdirplaylist.txt,"),w,$+(*,$did($dname,2).seltext,*))) write $($+(-,dl,$readn),2) $+(",$scriptdirplaylist.txt,") 
    did -d $dname 2 $did($dname,2).sel
  }
  if ($did = 3) { dialog -x $dname $dname } 
  if ($did = 13) { 
    var %x = 1, %seldir = $sdir($mircdir,Choose directory to add to playlist)
    while ($findfile(%seldir,*.mp3,%x)) { 
      write $+(",$scriptdirplaylist.txt,") $v1
      did -az $dname 2 $remove($nopath($v1),.mp3)
      inc %x
    }
  }
  if ($did = 14) { 
    write -c $+(",$scriptdirplaylist.txt,") 
    did -r $dname 2,11
    did -ra $dname 6 |>
  }
  if ($did = 16) { set %tmp3.status.end repeat } 
  if ($did = 17) { set %tmp3.status.end shuffle }
  if ($did = 19) { 
    var %sellocate = $input(Enter mp3 name...,qe,Find mp3...)
    set %tmp3.temp.selplay $did($dname,2).sel
    if ($read($+(",$scriptdirplaylist.txt,"),w,$+(*,%sellocate,*))) did -c $dname 2 $readn
  }
  if ($did = 21) { 
    splay $read($+(",$scriptdirplaylist.txt,")) 
    did -c $dname 2 $readn 
    set %tmp3.temp.selplay $did($dname,2).sel
    did -ra $dname 11 $iif($sound($insong.fname).title,$v1 - $sound($insong.fname).artist - $gmt($calc($insong.length / 1000),$iif($calc($insong.length /1000) > 3600,hh:nn:ss,nn:ss)),$did(tmp3,2).seltext - Unknown artist)
    did -ra $dname 6 ||
  }    
  if ($did = 20) { dialog -m tmp3vol tmp3vol }
}

on *:dialog:tmp3:sclick:*:{ 
  if ($did = 6) { 
    if ($did($dname,2).sel != %tmp3.temp.selplay) { 
      set %tmp3.temp.selplay $did($dname,2).sel
      splay -p $read($+(",$scriptdirplaylist.txt,"),$did($dname,2).sel)
      did -ra tmp3 11 $iif($sound($insong.fname).title,$v1 - $sound($insong.fname).artist - $gmt($calc($insong.length / 1000),$iif($calc($insong.length /1000) > 3600,hh:nn:ss,nn:ss)),$did(tmp3,2).seltext - Unknown artist)
      did -ra tmp3 6 ||
    }
    else {
      if (!$insong) { 
        set %tmp3.temp.selplay $did($dname,2).sel
        splay -p $read($+(",$scriptdirplaylist.txt,"),$did($dname,2).sel)
        did -ra tmp3 11 $iif($sound($insong.fname).title,$v1 - $sound($insong.fname).artist - $gmt($calc($insong.length / 1000),$iif($calc($insong.length /1000) > 3600,hh:nn:ss,nn:ss)),$did(tmp3,2).seltext - Unknown artist)
        did -ra tmp3 6 ||
      }
      else {
        if (!%tmp3.temp.pause) { 
          splay pause
          set %tmp3.temp.pause true
          did -ra tmp3 6 |>
          halt 
        }
        if (%tmp3.temp.selplay) { 
          splay resume
          unset %tmp3.temp.pause
          did -ra  tmp3 6 ||
          halt
        }
      }
    }
  }
  if ($did = 7) { tmp3stop }
  if ($did = 5) {
    did -c $dname 2 $calc($did($dname,2).sel - 1)
    set %tmp3.temp.selplay $did($dname,2).sel
    splay -p $read($+(",$scriptdirplaylist.txt,"),$did($dname,2).sel)
    did -ra tmp3 11 $iif($sound($insong.fname).title,$v1 - $sound($insong.fname).artist - $gmt($calc($insong.length / 1000),$iif($calc($insong.length /1000) > 3600,hh:nn:ss,nn:ss)),$did(tmp3,2).seltext - Unknown artist)
    did -ra tmp3 6 ||
  }
  if ($did = 8) {
    did -c $dname 2 $calc($did($dname,2).sel + 1)
    set %tmp3.temp.selplay $did($dname,2).sel
    splay -p $read($+(",$scriptdirplaylist.txt,"),$did($dname,2).sel)
    did -ra tmp3 11 $iif($sound($insong.fname).title,$v1 - $sound($insong.fname).artist - $gmt($calc($insong.length / 1000),$iif($calc($insong.length /1000) > 3600,hh:nn:ss,nn:ss)),$did(tmp3,2).seltext - Unknown artist)
    did -ra tmp3 6 ||
  }
}

alias -l tmp3stop { 
  splay stop
  did -ra tmp3 6 |>
  did -ra tmp3 11 No song currently playing...
}

on *:MP3END:{ 
  if (%tmp3.status.end = repeat) { splay -p $read($+(",$scriptdirplaylist.txt,"),%tmp3.temp.selplay) } 
  if (%tmp3.status.end = shuffle) { 
    splay $read($+(",$scriptdirplaylist.txt,")) 
    if ($dialog(tmp3)) { 
      did -c tmp3 2 $readn 
      set %tmp3.temp.selplay $did($dname,2).sel
      did -ra tmp3 11 $iif($sound($insong.fname).title,$v1 - $sound($insong.fname).artist - $gmt($calc($insong.length / 1000),$iif($calc($insong.length /1000) > 3600,hh:nn:ss,nn:ss)),$did(tmp3,2).seltext - Unknown artist)
      did -ra tmp3 6 ||
    }
  }
}

dialog tmp3vol {
  title "Volume.."
  size -1 -1 171 27
  option pixels
  button "<", 1, 4 2 48 21, flat
  button ">", 2, 52 2 48 21, flat
  check "Mute", 3, 104 3 64 17
}

on *:dialog:tmp3vol:*:*:{ 
  if ($devent = sclick || $devent = uclick) { 
    if ($did = 1) { if ($vol(master) > 655.35) { var %vol = $calc($vol(master) - 655.35) | vol -v %vol } }
    if ($did = 2) { if ($vol(master) < 65535) { var %vol = $calc($vol(master) + 655.35) | vol -v %vol } } 
    if ($did = 3) { 
      if ($did($dname,3).state = 1) { 
        set -e %vol.temp.current $vol(master) 
        vol -v 0 
      }
      if ($did($dname,3).state = 0) { 
        vol -v %vol.temp.current
        unset %vol.temp.current
      }   
    }
  }
}

Comments

Sign in to comment.
Mudkipz   -  Jan 20, 2008

well done dude, thats an ownage script, you should make one that shows what u are listning to on mirc and wmp too =) keep it up

 Respond  
guest598594   -  Nov 12, 2007

for the blank button, u should at least write stop or something...

 Respond  
TopaZ_   -  Nov 10, 2007

Thank you. :)

 Respond  
G13AoUsTiS   -  Nov 10, 2007

good job TopaZ_ =) Keep it going!

 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.