Thursday 9 April 2015

remote mp3

son 1:LOAD: {
  set %mp3dir $$sdir(c:\,MP3 Directory)
  set %totalmp3line $line(@PlayList,0)
  set %currentmp3line 1
  set %mp3stopexit ON
  set %mp3continuous ON
  set %mp3repeat OFF
  set %mp3shuffle OFF
  set %mutemp3
}

alias mp3player {
  window -kl @PlayList
  clear @PlayList
  if ( %mp3dir == $null ) { set %mp3dir $$sdir(c:\,MP3 Directory) }
  titlebar @PlayList : $$findfile(%mp3dir,*.mp3,0,aline 15 @PlayList $1-) tracks
  .splay stop
  set %currentmp3line 1
}

alias volup {
  set %currentvolume $vol(mp3)
  inc %currentvolume 5000
  if ( %currentvolume > 65535 ) { set %currentvolume 65535 }
  vol -p %currentvolume
}

alias voldown {
  set %currentvolume $vol(mp3)
  dec %currentvolume 5000
  if ( %currentvolume < 0 ) { set %currentvolume 0 }
  vol -p %currentvolume
}

alias volmute {
  if ( $vol(mp3).mute == $false ) {
    vol -pu1 | set %mutemp3 $chr(149)
  }
  else { vol -pu2 | set %mutemp3 }
}

alias mp3seek {
  if ( $1 == next ) {
    if ( $inmp3 != $false ) {
      set %mp3len $inmp3.length
      set %mp3pos $inmp3.pos
      .splay seek $calc( %mp3pos + 250 )
      if ( %mp3pos > %mp3len ) { .splay seek %mp3len }
    }
  }
}
if ( $1 == prev ) {
  if ( $inmp3 != $false ) {
    set %mp3len $inmp3.length
    set %mp3pos $inmp3.pos
    .splay seek $calc( %mp3pos - 250 )
    if ( %mp3pos > %mp3len ) { .splay seek 0 }
  }
}
if ( $1 == nextmp3 ) {
  cline 15 @PlayList %currentmp3line
  inc %currentmp3line
  if ( %currentmp3line > %totalmp3line ) { set %currentmp3line 1 }
  cline 7 @PlayList %currentmp3line
  .splay $line(@PlayList,%currentmp3line)
}
if ( $1 == prevmp3 ) {
  cline 15 @PlayList %currentmp3line
  if ( %currentmp3line == 1 ) { goto play }
  dec %currentmp3line
  :play
  cline 7 @PlayList %currentmp3line
  .splay $line(@PlayList,%currentmp3line)
}
if (%kutuconnect == ON) { /msg #alamanda «» [ psyloinc MP3 ] Now Playing [ $nopath($inmp3.fname) - $calc($int($calc( ($inmp3.length / 38 ) /60 ))) $+ $chr(58) $+ $calc( $int($calc( ($inmp3.length / 38.3 ))) - ($int($calc(($inmp3.length / 38.3 ) / 60 ))*60))) ] for [ $me ] «» }
else { /msg chan 14«» 10[ 8 psyloinc MP 3 10] 9 Now Playing 10[ 8 $nopath($inmp3.fname) - $calc($int($calc( ($inmp3.length / 38 ) /60 ))) $+ $chr(58) $+ $calc( $int($calc( ($inmp3.length / 38.3 ))) - ($int($calc(($inmp3.length / 38.3 ) / 60 ))*60))) 10] 14«»}
}

alias inid3info {
  window -k @Mp3Info 50 50 550 164
  aline @Mp3Info 9,1Filename : $nopath($inmp3.fname)
  aline @Mp3Info 9,1Path : $nofile($inmp3.fname)
  aline @Mp3Info 9,1Artist : $mp3($inmp3.fname).artist
  aline @Mp3Info 9,1Title : $mp3($inmp3.fname).title
  aline @Mp3Info 9,1Album : $mp3($inmp3.fname).album
  aline @Mp3Info 9,1Bitrate : $mp3($inmp3.fname).bitrate kbps
  aline @Mp3Info 9,1Sample : $mp3($inmp3.fname).sample khz
  aline @Mp3Info 9,1Mode : $mp3($inmp3.fname).mode
  aline @Mp3Info 9,1Length : $calc($int($calc( ($inmp3.length / 38 ) /60 ))) $+ $chr(58) $+ $calc( $int($calc( ($inmp3.length / 38.3 ))) - ($int($calc(($inmp3.length / 38.3 ) / 60 ))*60)))
}

alias id3info {
  window -k @Mp3Info 50 50 550 150
  aline @Mp3Info 9,1Filename : $nopath($sline(@PlayList,1))
  aline @Mp3Info 9,1Path : $nofile($sline(@PlayList,1))
  aline @Mp3Info 9,1Artist : $mp3($sline(@PlayList,1)).artist
  aline @Mp3Info 9,1Title : $mp3($sline(@PlayList,1)).title
  aline @Mp3Info 9,1Album : $mp3($sline(@PlayList,1)).album
  aline @Mp3Info 9,1Bitrate : $mp3($sline(@PlayList,1)).bitrate kbps
  aline @Mp3Info 9,1Sample : $mp3($sline(@PlayList,1)).sample khz
  aline @Mp3Info 9,1Mode : $mp3($sline(@PlayList,1)).mode
  aline @Mp3Info 9,1Length : $duration($int($calc( $file($sline(@PlayList,1)).size / 15876.24752 - 2)))
}

alias mp3help {
  window -k @Mp3Help 50 50 300 275
  aline 4 @Mp3Help Mp3 Player By NUCLEAR TEAM
  aline @Mp3Help        Function Keys :
  aline @Mp3Help 4 z : Previous Mp3 Play
  aline @Mp3Help 4 x : Play selected Mp3
  aline @Mp3Help 4 c : Pause Mp3 play
  aline @Mp3Help 4 f : Resume Mp3 play
  aline @Mp3Help 4 v : Stop Mp3 play
  aline @Mp3Help 4 b : Next Mp3 Play
  aline @Mp3Help 4 a : Seeking previous in mp3
  aline @Mp3Help 4 s : Seeking next in mp3
  aline @Mp3Help 4 + : Increase Volume
  aline @Mp3Help 4 -  : Decrease Volume
  aline @Mp3Help 4 * : Mute Volume
  aline @Mp3Help 4 Del : Delete selected Mp3
  aline @Mp3Help 4 Enter : Play selected Mp3
}

on 1:keydown:@PlayList:*: {
  if ( $keychar == x ) { plmp3 }
  if ( $keychar == c ) { .splay pause }
  if ( $keychar == v ) { cline 15 @PlayList %currentmp3line | .splay stop }
  if ( $keychar == f ) { .splay resume }

  if ( $keyval == 46 ) { delmp3 }
  if ( $keyval == 107 ) { volup }
  if ( $keyval == 109 ) { voldown }
  if ( $keyval == 106 ) { volmute }
  if ( $keyval == 65 ) { mp3seek prev }
  if ( $keyval == 83 ) { mp3seek next }
  if ( $keyval == 90 ) { mp3seek prevmp3 }
  if ( $keyval == 66 ) { mp3seek nextmp3 }
}

on 1:mp3end: {
  if ( $window(@PlayList).state != $null ) && ( %totalmp3line != 0 ) && ( %mp3continuous == ON ) {
    if ( %mp3repeat == ON ) { goto play }
    cline 15 @PlayList %currentmp3line
    if ( %mp3shuffle == ON ) {
      set %totalmp3line $line(@PlayList,0)
      set %currentmp3line $rand(1,%totalmp3line)
      goto play
    }
    inc %currentmp3line
    if ( %currentmp3line > %totalmp3line ) { set %currentmp3line 1 }
    :play
    cline 7 @PlayList %currentmp3line
    .splay $line(@PlayList,%currentmp3line)
    if (%kutuconnect == ON) { /msg #alamanda «» [ þ§¥£öÍñÇ-[MP3] ] Now Playing [ $nopath($inmp3.fname) - $calc($int($calc( ($inmp3.length / 38 ) /60 ))) $+ $chr(58) $+ $calc( $int($calc( ($inmp3.length / 38.3 ))) - ($int($calc(($inmp3.length / 38.3 ) / 60 ))*60))) ] for $me «» }
    else { /msg #alamanda   14,1«» 10,1[ 8,1 þ§¥£öÍñÇ-[MP3]™ 10] 9,1 Now Playing 10,1[ 8,1 $nopath($inmp3.fname) - $calc($int($calc( ($inmp3.length / 38 ) /60 ))) $+ $chr(58) $+ $calc( $int($calc( ($inmp3.length / 38.3 ))) - ($int($calc(($inmp3.length / 38.3 ) / 60 ))*60))) 10] 14«» }
  }
}

on 1:close:@PlayList: {
  ;  set %totalmp3line $line(@PlayList,0)
  ;  set %currentline 1
  ;  set %plsfilename playlist
  ;  write -c %plsfilename
  ;  :next
  ;  write %plsfilename $line(@PlayList,%currentline)
  ;  inc %currentline
  ;  if ( %currentline > %totalmp3line ) { goto end }
  ;  goto next
  ;  :end
  mp3stopexit
}

alias mp3stopexit {
  if ( %mp3stopexit == ON ) { .splay stop }
}

alias plmp3 {
  .set %totalmp3line $line(@PlayList,0)
  .splay stop
  .if ( $sline(@PlayList,1) == $null ) { halt }
  .if ( %currentmp3line == $null ) { set %currentmp3line 1 }
  .cline 15 @PlayList %currentmp3line
  .set %currentmp3line $sline(@PlayList,1).ln
  .cline 7 @PlayList %currentmp3line
  .splay $sline(@PlayList,1)
  if (%kutuconnect == ON) { /msg #alamanda  «» [ þ§¥£öÍñÇ-[mp3]™ ] Now Playing [ $nopath($inmp3.fname) - $calc($int($calc( ($inmp3.length / 38 ) /60 ))) $+ $chr(58) $+ $calc( $int($calc( ($inmp3.length / 38.3 ))) - ($int($calc(($inmp3.length / 38.3 ) / 60 ))*60))) ] for [ $me ] «» }
  else { /msg alamanda   14,1«» 10,1[ 8,1 þ§¥£öÍñÇ-[MP3]™ 10] 9,1 Now Playing 10,1[ 8,1 $nopath($inmp3.fname) - $calc($int($calc( ($inmp3.length / 38 ) /60 ))) $+ $chr(58) $+ $calc( $int($calc( ($inmp3.length / 38.3 ))) - ($int($calc(($inmp3.length / 38.3 ) / 60 ))*60))) 10] 14«» }
}

alias addmp3dir {
  set %totalmp3line $line(@PlayList,0)
  set %addedmp3 $$findfile($$sdir(c:\,MP3 Directory),*.mp3,0,aline 15 @PlayList $1-)
  set %totalmp3line $calc(%totalmp3line + %addedmp3)
  titlebar @PlayList : %totalmp3line tracks
}

alias addmp3file {
  set %totalmp3line $line(@PlayList,0)
  aline 15 @PlayList $$sfile(c:\*.mp3,Add File to PlayList,Add)
  inc %totalmp3line
  titlebar @PlayList : %totalmp3line tracks
}

alias delmp3 {
  if ( $sline(@PlayList,1) != $null ) {
    set %totalmp3line $line(@PlayList,0)
    dline @PlayList $sline(@PlayList,1).ln
    dec %totalmp3line
    titlebar @PlayList : %totalmp3line tracks
  }

}
menu @PlayList {
  dclick:/plmp3
  -=| Mp3 Player |=-:/halt
  -
  Play:/plmp3
  Pause:/.splay pause
  Resume:/.splay resume
  $iif($inmp3 == $false, $style(2)) Stop:/.cline 15 @PlayList %currentmp3line | /.splay stop
  Previous Mp3:mp3seek prevmp3
  Next Mp3:mp3seek nextmp3
  -
  Repeat ( %mp3repeatmark ): {
    if ( %mp3repeat == ON ) { set %mp3repeat OFF | set %mp3repeatmark }
    else { set %mp3repeat ON | set %mp3repeatmark $chr(149) }
  }
  Random Play ( %mp3shufflemark ): {
    if ( %mp3shuffle == ON ) { set %mp3shuffle OFF | set %mp3shufflemark }
    else { set %mp3shuffle ON | set %mp3shufflemark $chr(149) }
  }
  -
  Volume ( + ):/volup
  Volume ( - ):/voldown
  Mute ( %mutemp3 ):/volmute
  -
  $iif($sline(@PlayList,0) == $null, $style(2)) File Info:/id3info
  -
  $iif($inmp3 == $false, $style(2)) Current Playing
  .$nopath($inmp3.fname) - $calc($int($calc( ($inmp3.length / 38 ) /60 ))) $+ $chr(58) $+ $calc( $int($calc( ($inmp3.length / 38.3 ))) - ($int($calc(($inmp3.length / 38.3 ) / 60 ))*60))):inid3info
  PlayList
  .Add File:/addmp3file
  .Add Directory:/addmp3dir
  .-
  .Delete File:/delmp3
  .-
  .Clear PlayList:/set %totalmp3line | /clear @PlayList | titlebar @PlayList : 0 track
  .Save PlayList:/mp3plsfile save
  .Load PlayList:/mp3plasfile load
  Settings
  .Set Mp3 Directory:set %mp3dir $$sdir(c:\,MP3 Directory)
  .Repeat Play ( %mp3repeat )
  ..ON:set %mp3repeat ON | set %mp3repeatmark $chr(149)
  ..OFF:set %mp3repeat OFF | set %mp3repeatmark
  .Shuffle Play ( %mp3shuffle )
  ..ON:set %mp3shuffle ON | set %mp3shufflemark $chr(149)
  ..OFF:set %mp3shuffle OFF | set %mp3shufflemark
  .Continuous Play ( %mp3continuous )
  ..ON:set %mp3continuous ON
  ..OFF:set %mp3continuous OFF
  .Stop Mp3 on Exit ( %mp3stopexit )
  ..ON:/set %mp3stopexit ON
  ..OFF:/set %mp3stopexit OFF
  -
  Help:/mp3help
  Exit:/window -c @PlayList | mp3stopexit
}
}
alias mp3plsfile {
if ( $1 == save ) {
  if ( $window(@PlayList).state != $null ) {
    set %totalmp3line $line(@PlayList,0)
    set %currentline 1
    set %plsfilename $$sfile($mircdir,Enter Filename,Save)
    write -c %plsfilename
    :next
    write %plsfilename $line(@PlayList,%currentline)
    inc %currentline
    if ( %currentline > %totalmp3line ) { goto end }
    goto next
    :end
    ;echo -s 9*** PlayList File has been saved ...
  }
}
}
if ( $1 == load ) {
if ( $window(@PlayList).state != $null ) {
  clear @PlayList
  set %plsfilename $$sfile($mircdir,Choose a PlayList File,Load)
  set %totalplsline $lines(%plsfilename)
  set %currentline 1
  :next
  aline 15 @PlayList $read -l $+ %currentline %plsfilename
  inc %currentline
  if ( %currentline > %totalplsline ) { goto end }
  goto next
  :end
  .splay stop
  set %totalmp3line $line(@PlayList,0)
  titlebar @PlayList : %totalmp3line tracks
  ;echo -s 9*** PlayList File has been loaded ...
}

}

alias mp3unload {
unset %addedmp3
unset %currentline
unset %currentmp3line
unset %currentvolume
unset %mp3continuous
unset %mp3dir
unset %mp3len
unset %mp3pos
unset %mp3repeat
unset %mp3repeatmark
unset %mp3shuffle
unset %mp3shufflemark
unset %mp3stopexit
unset %mutemp3
unset %plsfilename
unset %totalmp3line
unset %totalplsline
.unload -rs $script
}