aIRC — File Browser
aIRCv0.8.69 / aIRCv0.8.69 / addons / sound2.mrc
sound2.mrc — 32.47 KB — Download this file
;/**********************************************************************
; *
; * aIRC
; * Sound System (aircamp)
; *
; **********************************************************************/
;
;;
;
; -( aIRCamp )-
;
;;
alias aircamp {
var %d = _aircamp,%standardonopenroutines = 1,%flags,%mask,%new = 1
if ($dialog(%d)) { %new = 0 }
_dialog -m %d %d
if (-* iswm $1-) { var %flags = $1,%mask = $2- }
elseif ($1- != $null) { %mask = $1- }
if (w isin %flags) && ($window($gettok(%mask,1,32))) {
var %win = $gettok(%mask,1,32),%request = $gettok(%mask,2-,32),%text = There are $line(%win,0) matches for ' $+ %request $+ '.<CRLF>Do you want to playlist the matches?<CRLF>(Your old playlist will be lost)
if (%new == 0) && (o !isincs %flags) && (q !isincs %flags) && ($did(%d,2103).lines) && ($_not($_yesno(1,aIRCamp [/aircamp],1,%text))) { return }
%standardonopenroutines = 0
if (o isincs %flags) || (q !isincs %flags) { _aircamp.clearplaylist }
var %i = 1,%n = $line(%win,0)
while (%i <= %n) {
_aircamp.addfile $line(%win,%i)
inc %i
}
if ((q !isincs %flags) || (%new)) && ($line(%win,1) != $null) { _mp3.play -s $ifmatch }
}
if (%standardonopenroutines) {
_aircamp.clearplaylist
var %file1 = $_usrdir(misc\lastaircamplist1.dat),%file2 = $_usrdir(misc\lastaircamplist2.dat)
if ($isfile(%file1)) && ($isfile(%file2)) && ($lines(%file1) == $lines(%file2)) {
loadbuf -o %d 2102 " $+ %file1 $+ "
loadbuf -o %d 2103 " $+ %file2 $+ "
did -z %d 2102
}
if ($_mp3.inmp3.fname != $null) {
var %mfile = $ifmatch
_aircamp.addfile %mfile
_mp3.play -r %mfile
}
elseif ($_getsetup(mp3,aircamp.lastsong) != $null) { _mp3.play -v $ifmatch }
}
}
alias _aircamp.clearplaylist {
if ($dialog(_aircamp) == $null) { return }
did -r _aircamp 2102,2103
did -z _aircamp 2102
}
dialog _aircamp {
size -1 -1 162 60
option dbu
title "aIRCamp"
box "",1001,5 0 153 59
edit "",1002,8 5 147 10,autohs read
edit "",2002,8 5 125 10,autohs read hide
text "",1003,8 18 80 8
text "9:99:99/9:99:99",1004,8 37 39 8,right
list 1005,49 38 108 6,size
text "Vol:",1006,8 28 10 8
list 1007,19 28 42 6,size
text "Bal:",1008,66 28 10 8
list 1009,77 28 25 6,size
button "O",1010,105 27 10 8
button "TO",1011,115 27 10 8
button "EQ",1012,125 27 10 8
check "PL",1013,135 27 10 8,push
button "_",1014,145 27 10 8
edit "",1092,8 5 125 10,autohs read hide
button "| <",1041,8 46 17 11
button ">",1042,25 46 17 11
check "| |",1043,42 46 17 11,push
button "",1044,59 46 17 11
; "[&¯]"
button "> |",1045,76 46 17 11
button "&^",1015,97 46 17 11
check "S",1046,124 46 10 11,push
check "R",1047,134 46 10 11,push
check "M",1048,144 46 10 11,push
button "| <",2041,5 1 15 10,hide
button ">",2042,20 1 15 10,hide
check "| |",2043,35 1 15 10,hide push
button "",2044,50 1 15 10,hide
button "> |",2045,65 1 15 10,hide
check "S",2046,82 1 10 10,push hide
check "R",2047,92 1 10 10,push hide
check "M",2048,102 1 10 10,push hide
button "¯",2049,115 2 8 8,hide
box "",2101,5 57 153 113
list 2102,8 62 148 100,hsbar extsel
list 2103,8 62 148 100,hide extsel
button "add",2104,8 158 13 10
button "rem",2105,21 158 13 10
button "sel",2106,34 158 13 10
button "misc",2107,47 158 13 10
button "list",2108,60 158 13 10
button "up",2109,80 158 15 10
button "down",2110,95 158 15 10
check "id3",2111,141 158 15 10,push
; 1- playing?
; 2- pos
; 3- length
; 4- paused
list 2980,10 10 10 10,hide
button "",2991,10 100 30 15,cancel hide
button "",2992,10 100 30 15,ok hide
button "MDX Positioner",2993,10 10 10 10,hide
}
ON *:DIALOG:_aircamp:init:0:{
_mdx.init $_icofile(aircamp.ico,$scriptdir) title border sysmenu minbox
_mdx.SetFont $dname 1002 + 13 700 Tahoma
_mdx.SetFont $dname 1015,1003,1010,1011,1012,1013,1014,1004,1006,1041,1042,1043,1044,1045,1046,1047,1048,2041,2042,2043,2044,2045,2046,2047,2048,2049,2101,2102,2104,2105,2106,2107,2108,2109,2110,2111 + 13 400 Tahoma
_mdx.SetControlMDX dialog.mdx $dname 2993 Positioner minbox
_mdx.SetControlMDX bars.mdx $dname 1005 TrackBar
did -i $dname 1005 1 params 0 0 1 1 10 * * 10
_mdx.SetBorderStyle $dname 1005
did -i $dname 1005 1 ticfreq 1000
_mdx.SetControlMDX bars.mdx $dname 1007 TrackBar
_ampdll.setvolume $calc($vol(mp3) / 257)
did -i $dname 1007 1 params $vol(mp3) 0 65535 655 6554 * * 10
_mdx.SetBorderStyle $dname 1007
did -i $dname 1007 1 ticfreq 1000
_mdx.SetControlMDX bars.mdx $dname 1009 TrackBar
did -i $dname 1009 1 params $_ampdll.getpan -127 127 3 10 * * 10
_mdx.SetBorderStyle $dname 1009
did -i $dname 1009 1 ticfreq 1000
did -o $dname 2980 1 $iif($_mp3.inmp3,1,0)
did -o $dname 2980 2 $_mp3.inmp3.pos
did -o $dname 2980 3 $_mp3.inmp3.length
did -o $dname 2980 4 0
var %m = $_getsetup(mp3,aircamp.dialogminimized),%p = $_getsetup(mp3,aircamp.isplaylistopen)
if (%m) { _aircamp.minimize }
if (%p) {
did -c $dname 1013
if ($_not(%m)) {
_aircamp.restore
dialog -s $dname $calc(($window(-1).w - $dialog($dname).cw) / 2) $calc(($window(-1).h - $dialog($dname).ch) / 2) $dialog($dname).cw $dialog($dname).ch
}
}
if ($_getsetup(mp3,aircamp.pshuffle)) { did -c $dname 1046,2046 }
if ($_getsetup(mp3,aircamp.prandom)) { did -c $dname 1047,2047 }
if ($_getsetup(mp3,aircamp.pmute)) { did -c $dname 1048,2048 }
if ($_getsetup(mp3,aircamp.preadid3)) { did -c $dname 2111 }
_mdx.SetColor $dname 1002 background 0
_mdx.SetColor $dname 1002 text 56320
_mdx.SetColor $dname 1002 textbg 0
.timer_aircamp -m 0 500 _aircamp.timer +
_aircamp.timer +n
did -f $dname 2102
}
ON *:DIALOG:_aircamp:sclick:2993:{ }
ON *:DIALOG:_aircamp:sclick:1005:{
var %tmp = $did($dname,1005,1)
if ($gettok(%tmp,9,32) == end) {
_ampdll.seek $gettok(%tmp,1,32)
_aircamp.timer +n
}
}
ON *:DIALOG:_aircamp:sclick:1007:{
var %tmp = $did($dname,1007,1)
if ($gettok(%tmp,9,32) == end) {
var %tmp = $gettok(%tmp,1,32)
vol -p %tmp
_ampdll.setvolume $calc(%tmp / 257)
}
else { _ampdll.setvolume $calc($gettok(%tmp,1,32) / 257) }
}
ON *:DIALOG:_aircamp:sclick:1009:{ _ampdll.setpan $gettok($did($dname,1009,1),1,32) }
ON *:DIALOG:_aircamp:sclick:1010:{ soundsetup plugins }
ON *:DIALOG:_aircamp:sclick:1011:{ soundtargets }
ON *:DIALOG:_aircamp:sclick:1012:{ equalizer }
ON *:DIALOG:_aircamp:sclick:1013:{ _aircamp.restore -q }
ON *:DIALOG:_aircamp:sclick:1014:{ _aircamp.minimize }
ON *:DIALOG:_aircamp:sclick:1015:{ _aircamp.add file2 }
ON *:DIALOG:_aircamp:sclick:2049:{ _aircamp.restore }
ON *:DIALOG:_aircamp:sclick:1041,2041:{ _aircamp.prevnext - 0 }
ON *:DIALOG:_aircamp:sclick:1042,2042:{ _mp3.play -r $did($dname,1092) }
ON *:DIALOG:_aircamp:sclick:1043,2043:{ _aircamp.pause }
ON *:DIALOG:_aircamp:sclick:1044,2044:{ mp3 stop }
ON *:DIALOG:_aircamp:sclick:1045,2045:{ _aircamp.prevnext + 0 }
ON *:DIALOG:_aircamp:sclick:1046,2046:{ _aircamp.pshuffle }
ON *:DIALOG:_aircamp:sclick:1047,2047:{ _aircamp.prandom }
ON *:DIALOG:_aircamp:sclick:1048,2048:{ _aircamp.pmute }
ON *:DIALOG:_aircamp:sclick:2104:{
var %menu = $dname,%result
_popupdll.New %menu 16 16
_popupdll.AddItem %menu end + 0 0 add &file $cr _aircamp.add file
_popupdll.AddItem %menu end + 0 0 add &dir $cr _aircamp.add dir
;;; _popupdll.AddItem %menu end + 0 0 add &url $cr _aircamp.add url
_popupdll.Popup %menu + $mouse.dx $mouse.dy
%result = $result
_popupdll.Destroy %menu
if ($gettok(%result,1,32) == OK) && ($gettok(%result,4-,32) != $null) { $ifmatch }
}
ON *:DIALOG:_aircamp:sclick:2105:{
var %menu1 = $dname,%menu2 = %menu1 $+ misc,%result
_popupdll.New %menu2 16 16
_popupdll.AddItem %menu2 end + 0 0 remove &dead files $cr _aircamp.rem dead
_popupdll.AddItem %menu2 end + 0 0 &physically remove selected files $cr _aircamp.rem phys
_popupdll.New %menu1 16 16
_popupdll.AddItem %menu1 end + 0 0 rem &sel $cr _aircamp.rem sel
_popupdll.AddItem %menu1 end + 0 0 &crop $cr _aircamp.rem crop
_popupdll.AddItem %menu1 end + 0 0 rem &all $cr _aircamp.rem all
_popupdll.AddItem %menu1 end +> 0 0 rem &misc $cr %menu2
_popupdll.Popup %menu1 + $mouse.dx $mouse.dy
%result = $result
_popupdll.Destroy %menu1
_popupdll.Destroy %menu2
if ($gettok(%result,1,32) == OK) && ($gettok(%result,4-,32) != $null) { $ifmatch }
}
ON *:DIALOG:_aircamp:sclick:2106:{
var %menu = $dname,%result
_popupdll.New %menu 16 16
_popupdll.AddItem %menu end + 0 0 sel &all $cr _aircamp.sel all
_popupdll.AddItem %menu end + 0 0 sel &zero $cr _aircamp.sel zero
_popupdll.AddItem %menu end + 0 0 &inv sel $cr _aircamp.sel inv
_popupdll.Popup %menu + $mouse.dx $mouse.dy
%result = $result
_popupdll.Destroy %menu
if ($gettok(%result,1,32) == OK) && ($gettok(%result,4-,32) != $null) { $ifmatch }
}
ON *:DIALOG:_aircamp:sclick:2107:{
var %menu1 = $dname,%menu2 = %menu1 $+ misc,%result
_popupdll.New %menu2 16 16
_popupdll.AddItem %menu2 end + 0 0 sort list by &title $cr _aircamp.misc sorttitle
_popupdll.AddItem %menu2 end + 0 0 sort list by &filename $cr _aircamp.misc sortfile
_popupdll.AddItem %menu2 end + 0 0 sort list by &path and filename $cr _aircamp.misc sortpath
_popupdll.AddItem %menu2 end
_popupdll.AddItem %menu2 end + 0 0 r&everse list $cr _aircamp.misc sortreverse
_popupdll.AddItem %menu2 end + 0 0 &randomize list $cr _aircamp.misc sortrandom
_popupdll.New %menu1 16 16
_popupdll.AddItem %menu1 end + 0 0 file &info $cr _aircamp.misc info
_popupdll.AddItem %menu1 end +> 0 0 &sort list $cr %menu2
_popupdll.Popup %menu1 + $mouse.dx $mouse.dy
%result = $result
_popupdll.Destroy %menu1
_popupdll.Destroy %menu2
if ($gettok(%result,1,32) == OK) && ($gettok(%result,4-,32) != $null) { $ifmatch }
}
ON *:DIALOG:_aircamp:sclick:2108:{
var %menu = $dname,%result
_popupdll.New %menu 16 16
_popupdll.AddItem %menu end + 0 0 &load list $cr _aircamp.list load
_popupdll.AddItem %menu end + 0 0 &save list $cr _aircamp.list save
_popupdll.AddItem %menu end + 0 0 &new list $cr _aircamp.list new
_popupdll.Popup %menu + $mouse.dx $mouse.dy
%result = $result
_popupdll.Destroy %menu
if ($gettok(%result,1,32) == OK) && ($gettok(%result,4-,32) != $null) { $ifmatch }
}
ON *:DIALOG:_aircamp:sclick:2109:{ _aircamp.moveup }
ON *:DIALOG:_aircamp:sclick:2110:{ _aircamp.movedown }
ON *:DIALOG:_aircamp:sclick:2111:{ _setsetup mp3 aircamp.preadid3 $did($dname,2111).state }
ON *:DIALOG:_aircamp:sclick:2991:{
var %file1 = $_usrdir(misc\lastaircamplist1.dat),%file2 = $_usrdir(misc\lastaircamplist2.dat)
write -c " $+ %file1 $+ "
write -c " $+ %file2 $+ "
if ($did($dname,2103).lines) {
filter -if $dname 2102 " $+ %file1 $+ " *
filter -if $dname 2103 " $+ %file2 $+ " *
did -z $dname 2102
}
var %m = 0,%s = p,%p = 0
if ($calc($dialog($dname).ch / $dbuh) < 55) { %m = 1 }
if ($did($dname,1013).state) { %p = 1 }
_setsetup mp3 aircamp.dialogminimized %m
_setsetup mp3 aircamp.isplaylistopen %p
mp3 stop
}
ON *:DIALOG:_aircamp:sclick:2992:{
if ($dialog($dname).focus == 2102) {
var %file = $gettok($did($dname,2103,$did($dname,2102).sel),1,34)
if ($isfile(%file)) { _mp3.play -s %file }
}
halt
}
ON *:DIALOG:_aircamp:dclick:2102:{
var %file = $gettok($did($dname,2103,$did($dname,2102).sel),1,34)
_mp3.play -s %file
}
alias _sound.aretherequiredwinampdllsloadedtoplaymymetallicamp3s? {
if ($_ampdll.PluginDescription(output) == $null) { return 0 }
var %i = $_ampdll.PluginInputcount
while (%i) {
if ($istok($_ampdll.PluginTypelist(%i,1),mp3,59)) { return 1 }
dec %i
}
return 0
}
; _mp3.stop <stop in dialog?>
alias _mp3.stop {
if ($inmp3) { splay -p stop }
if ($_mp3.inmp3) { _ampdll.Stop }
if ($1) && ($dialog(_aircamp)) {
did -u _aircamp 1043,2043
did -o _aircamp 2980 1,2,4 0
}
}
alias _mp3.inmp3 {
if ($inmp3) { return $true }
return $iif(ok * iswm $_ampdll.Filename,$true,$false)
}
alias _mp3.inmp3.fname {
if ($inmp3) { return $inmp3.fname }
var %tmp = $_ampdll.Filename
if (OK * iswm %tmp) { return $gettok(%tmp,2-,32) }
return
}
alias _mp3.inmp3.pos {
if ($inmp3) { return $inmp3.pos }
var %tmp = $_ampdll.Position
if (OK * iswm %tmp) { return $gettok(%tmp,2-,32) }
return 0
}
alias _mp3.inmp3.length {
if ($inmp3) { return $inmp3.length }
var %tmp = $_ampdll.Length
if (OK * iswm %tmp) { return $gettok(%tmp,2-,32) }
return 0
}
alias _aircamp.pshuffle {
var %d = _aircamp
did $iif($did(%d,$did).state,-c,-u) %d 1046,2046
_setsetup mp3 aircamp.pshuffle $did(%d,1046).state
}
alias _aircamp.prandom {
var %d = _aircamp
did $iif($did(%d,$did).state,-c,-u) %d 1047,2047
_setsetup mp3 aircamp.prandom $did(%d,1047).state
}
alias -l _aircamp.prevnext {
var %d = _aircamp,%inc = $iif($1 == -,-,+) $+ 1,%flags = $iif($2,-s,-v),%file,%line,%wm,%total,%newfile,%shuffle,%repeat,%curr
if ($dialog(%d) == $null) { return }
%shuffle = $did(%d,1046).state
%repeat = $did(%d,1047).state
%total = $did(%d,2103).lines
%file = $did(%d,1092)
%wm = %file $+ "*
if ($didwm(%d,2103,%wm,1)) { %line = $ifmatch }
else { %line = 0 }
if (%total == 1) {
if (%repeat) {
_mp3.play %flags %file
}
}
elseif (%total > 1) {
if (%shuffle) {
while ($rand(1,%total)) {
if ($ifmatch != %line) {
_mp3.play %flags $gettok($did(%d,2103,$ifmatch),1,34)
break
}
}
}
else {
%curr = $calc(%line + %inc)
if (%curr > %total) {
if (%repeat) { %curr = 1 }
else { return }
}
if (%curr < 0) {
if (%repeat) { %curr = %total }
else { return }
}
_mp3.play %flags $gettok($did(%d,2103,%curr),1,34)
}
}
}
alias _aircamp.pmute {
var %d = _aircamp,%file = $did(%d,1092,1),%newstate = $iif($did(%d,$did).state,1,0)
if (%newstate == 0) && ($isfile(%file)) && ($_not($_mp3.inmp3)) {
;play -p " $+ %file $+ " $did(%d,2980,2)
_ampdll.Play %file
if ($did(%d,2980,2)) { _ampdll.Seek $ifmatch }
}
else { _mp3.stop 0 }
did $iif(%newstate,-c,-u) %d 1048,2048
_setsetup mp3 aircamp.pmute %newstate
_aircamp.timer +n
}
alias -l _aircamp.pause {
var %d = _aircamp
did $iif($did(%d,$did).state,-c,-u) %d 1043,2043
if ($did(%d,1043).state) {
if ($did(%d,1048).state == 0) {
if ($inmp3) { splay -p pause }
else { _ampdll.Pause }
}
did -c %d 1043,2043
}
else {
if ($did(%d,1048).state == 0) {
if ($inmp3) { splay -p resume }
else { _ampdll.Unpause }
}
did -u %d 1043,2043
}
did -o %d 2980 4 $did(%d,1043).state
}
alias -l _aircamp.minimize {
var %d = _aircamp
did -h %d 1001,1002,1003,1004,1006,1010,1011,1012,1013,1014,1041,1042,1043,1044,1045,1046,1047,1048,2101,2102,2104,2105,2106,2107,2108,2109,2110
did -v %d 2041,2042,2043,2044,2045,2046,2047,2048,2049
dialog -s %d $dialog(%d).x $dialog(%d).y $calc(125 * $dbuw) $calc(12 * $dbuh)
}
alias -l _aircamp.restore {
var %d = _aircamp
if ($1 != -q) {
did -v %d 1001,1002,1003,1004,1006,1010,1011,1012,1013,1014,1041,1042,1043,1044,1045,1046,1047,1048,2101,2102,2104,2105,2106,2107,2108,2109,2110
did -h %d 2041,2042,2043,2044,2045,2046,2047,2048,2049
}
dialog -s %d $dialog(%d).x $dialog(%d).y $calc(162 * $dbuw) $calc($iif($did(%d,1013).state,172,60) * $dbuh)
}
alias _aircamp.timer {
var %d = _aircamp
if ($dialog(%d) == $null) {
.timer_aircamp off
return
}
var %mute = $did(%d,1048).state,%voline = $did(%d,1007,1),%balanceline = $did(%d,1009,1),%next = 0
if ($istok(none end,$gettok(%voline,9,32),32)) && ($vol(mp3) != $gettok(%voline,1,32)) { did -i %d 1007 1 params $ifmatch }
if ($istok(none end,$gettok(%balanceline,9,32),32)) && ($_ampdll.getpan != $gettok(%balanceline,1,32)) { did -i %d 1009 1 params $ifmatch }
if ($did(%d,2980,1)) {
did -e %d 1042,1043,1044,2042,2043,2044,1004,1005
if (%mute) && ($_mp3.inmp3) {
_mp3.stop 0
did -u %d 1043,2043
}
if ($_mp3.inmp3) {
var %tpos = $_mp3.inmp3.pos,%length = $_mp3.inmp3.length
did -o %d 1004 1 $_aircamp.duration(%tpos,0) $+ / $+ $_aircamp.duration(%length,0)
did -o %d 2980 2 %tpos
did -o %d 2980 3 %length
}
else {
var %tpos = $did(%d,2980,2),%length = $did(%d,2980,3),%pause = $did(%d,2980,4)
if (%pause == 0) && (n !isincs $1) { inc %tpos 500 }
if (%tpos >= %length) { _aircamp.prevnext + 1 }
else {
did -o %d 2980 2 %tpos
did -o %d 1004 1 $_aircamp.duration(%tpos,0) $+ / $+ $_aircamp.duration(%length,0)
}
}
if (%length > %tpos) && ($istok(none end,$gettok($did(%d,1005,1),9,32),32)) { did -i %d 1005 1 params %tpos 0 %length 1000 10000 * * 10 }
}
else {
did -b %d 1043,1044,2043,2044,1004,1005
did -o %d 1004 1 0:00/0:00
if ($did(%d,1092) != $null) { did -e %d 1042,2042 }
else { did -b %d 1042,2042 }
did -i %d 1005 1 params 0 0 1 1000 10000 * * 10
_mp3.stop 1
}
}
;;; ON *:MP3END:{ _aircamp.prevnext + 1 }
alias -l _aircamp.duration {
if ($1 > 0) {
if ($2) { var %n = $1 }
else { var %n = $int($calc($1 /1000)) }
var %h = $int($calc(%n / 3600)),%m = $int($calc((%n % 3600) / 60)),%s = $calc(%n % 60)
if (%s < 10) { %s = 0 $+ %s }
if (%h) {
if (%m < 10) { %m = 0 $+ %m }
return %h $+ : $+ %m $+ : $+ %s
}
return %m $+ : $+ %s
}
return 0:00
}
alias _aircamp.add {
var %d = _aircamp,%f,%wm,%k
if ($dialog(%d) == $null) { return }
if (file* iswm $1-) {
var %k = $iif($_list.get(mp3dirs,1) != $null,$_list.get(mp3dirs,1),$mp3dir) $+ *.mp3,%f = $$dir="Add file to playlist" %k
if ($dialog(%d) == $null) { return }
dialog -v %d
if (*.mp3 !iswm %f) && (*.mp2 !iswm %f) { return }
_aircamp.addfile %f
%wm = %f $+ "*
if ($didwm(%d,2103,%wm,1)) { did -c %d 2102 $ifmatch }
if (*2 iswm $1-) { _mp3.play -s %f }
}
else {
%k = $iif($_list.get(mp3dirs,1) != $null,$_list.get(mp3dirs,1),$mp3dir)
%f = $$sdir="Add dir to playlist" %k
if ($dialog(%d) == $null) { return }
dialog -v %d
%wm = $findfile(%f,*.mp3,0,_aircamp.addfile $1-)
}
}
alias _aircamp.rem {
var %d = _aircamp
if ($dialog(%d) == $null) { return }
if ($1- == all) { _aircamp.clearplaylist }
elseif ($1- == dead) {
var %i = $did(%d,2103).lines,%file
while (%i) {
%file = $gettok($did(%d,2103,%i),1,34)
if ($isfile(%file) == $false) { did -d %d 2102,2103 %i }
dec %i
}
}
elseif ($1- == crop) {
var %i = 1,%n = $did(%d,2102,0).sel,%l,%win = @__aircampremcrop
_openwins %win
while (%i <= %n) {
aline %win $did(%d,2103,$did(%d,2102,%i).sel)
inc %i
}
_aircamp.dialog.win2playlist %win c
}
else {
var %delfile = $iif($1- == phys,1,0)
if (%delfile) && ($_not($_yesno(1,aIRCamp [/aircamp],1,Using this command will remove all selected files PERMANENTLY from disk. Are you SURE you want to do this?))) { return }
var %i = $did(%d,2102,0).sel,%l,%file
while (%i) {
%l = $did(%d,2102,%i).sel
%file = $gettok($did(%d,2103,%l),1,34)
did -ukd %d 2102,2103 %l
if (%delfile) && ($isfile(%file)) { .remove " $+ %file $+ " }
dec %i
}
}
did -z %d 2102
}
alias _aircamp.sel {
var %d = _aircamp
if ($dialog(%d) == $null) { return }
if ($1- == inv) {
var %si = 1,%sn = $did(%d,2102,0).sel,%currsel = 0,%lastsel = 0,%ti,%n = $did(%d,2102).lines,%win = @__aircampinvseltmp
_openwins %win
while (%si <= %sn) {
%currsel = $did(%d,2102,%si).sel
if ($calc(%currsel - %lastsel) > 1) {
%ti = %lastsel + 1
while (%ti < %currsel) {
aline %win did -ck %d 2102 %ti
inc %ti
}
}
aline %win did -uk %d 2102 %currsel
%lastsel = %currsel
inc %si
}
inc %currsel
while (%currsel <= %n) {
aline %win did -ck %d 2102 %currsel
inc %currsel
}
var %i = 1,%n = $line(%win,0)
while (%i <= %n) {
$line(%win,%i)
inc %i
}
close -@ %win
}
else {
var %n = $did(%d,2102).lines
while (%n) {
if ($1- == all) { did -ck %d 2102 %n }
else { did -uk %d 2102 %n }
dec %n
}
}
}
alias _aircamp.misc {
var %d = _aircamp
if ($dialog(%d) == $null) { return }
if ($1- == sortreverse) {
var %i = $did(%d,2103).lines,%win = @__aircampmiscreverse
_openwins %win
while (%i) {
aline %win $did(%d,2103,%i)
dec %i
}
_aircamp.dialog.win2playlist %win
}
elseif ($1- == sortrandom) {
var %i,%win1 = @__aircampmiscrandom1,%win2 = @__aircampmiscrandom2
_openwins %win1 %win2
filter -iw %d 2103 %win1 *
while ($line(%win1,0)) {
%i = $rand(1,$ifmatch)
aline %win2 $line(%win1,%i)
dline %win1 %i
dec %i
}
_aircamp.dialog.win2playlist %win2
}
elseif (sort* iswm $1-) {
var %col,%win1 = @__aircampmiscsort1
if ($1- == sorttitle) { %col = 7 }
elseif ($1- == sortfile) { %col = 2 }
else { %col = 1 }
_openwins %win1
filter -iwt %col 34 %d 2103 %win1
if ($1- == sortpath) {
var %win2 = @__aircampmiscsort2
_openwins %win2
filter -ww %win1 %win2 *
clear %win1
var %i = 1,%dir,%currdir,%text,%tmp
while ($line(%win2,0)) {
var %i = 1,%tmp = 0
while (%i <= $line(%win2,0)) {
var %text = $line(%win2,%i),%dir = $nofile($gettok(%text,1,34))
if (%tmp == 0) { %currdir = %dir }
inc %tmp
if (%dir == %currdir) {
aline %win1 %text
dline %win2 %i
}
else { inc %i }
}
;
}
close -@ %win2
}
_aircamp.dialog.win2playlist %win1
}
else {
var %file = $gettok($did(%d,2103,$did(%d,2102,1).sel),1,34)
if ($isfile(%file)) {
_ampdll.FileInfo %file
if (ok * !iswm $result) { error.a File info: $gettok($result,3-,32) }
}
}
}
alias _aircamp.list {
var %d = _aircamp
if ($dialog(%d) == $null) { return }
if ($1- == new) { _aircamp.clearplaylist }
elseif ($1- == load) {
var %k = $iif($_list.get(mp3dirs,1) != $null,$_list.get(mp3dirs,1),$mp3dir) $+ *.m3u,%f = $$dir="Load playlist" %k,%win = @__aircamploadlist
if ($dialog(%d) == $null) { return }
dialog -v %d
if ($isfile(%f) == $false) {
error.a File not found: ' $+ %f $+ '
return
}
if (*.m3u iswm %f) {
_aircamp.clearplaylist
_openwins %win
loadbuf %win " $+ %f $+ "
var %i = 1,%n = $line(%win,0),%text,%dir = $nofile(%f),%mfile,%duration,%desc,%ytmp,%ext = 0
while (%i <= %n) {
%text = $line(%win,%i)
if (%text == #EXTM3U) { var %mfile,%duration,%desc,%ext = 0 }
elseif (#EXTINF:* iswm %text) { var %mfile,%ytmp = $gettok(%text,2-,58),%duration = $gettok(%ytmp,1,44),%desc = $gettok(%ytmp,2-,44),%ext = 1 }
else {
%mfile = %text
%mfile = $replace(%mfile,/,\)
if (?:* !iswm %mfile) {
if (\* iswm %mfile) { %mfile = $left(%f,2) $+ %mfile }
else { %mfile = $nofile(%f) $+ \ $+ %mfile }
}
while (\\ isin %mfile) { %mfile = $replace(%mfile,\\,\) }
if (%desc == $null) { var %desc = $nopath(%mfile),%desc = $gettok(%desc,1- [ $calc($numtok(%desc,46) - 1) ] ,46) }
if (%duration isnum) { %duration = $_aircamp.duration(%duration,1) }
else { %duration = ?? }
did -a %d 2103 %mfile $+ " $+ $nopath(%mfile) $+ " $+ %ext $+ " $+ %duration $+ "0"0" $+ %desc
if (%duration != ??) { did -a %d 2102 %desc ( $+ %duration $+ ) }
else { did -a %d 2102 %desc }
var %mfile,%duration,%desc,%ext = 0
}
inc %i
}
did -z %d 2102
close -@ %win
}
elseif (*.pls iswm %f) && ($_readini(%f,playlist,version) == 2) && ($_isint($_readini(%f,playlist,NumberOfEntries))) {
var %i = 1,%n = $ifmatch
while (%i <= %n) {
var %mfile = File $+ %i,%desc = Title $+ %i,%duration = Length $+ 1,%ext = 0
var %mfile = $_readini(%f,playlist,%mfile),%desc = $_readini(%f,playlist,%desc),%duration = $_readini(%f,playlist,%duration)
if (%mfile != $null) {
%mfile = $replace(%mfile,/,\)
if (?:* !iswm %mfile) {
if (\* iswm %mfile) { %mfile = $left(%f,2) $+ %mfile }
else { %mfile = $nofile(%f) $+ \ $+ %mfile }
}
while (\\ isin %mfile) { %mfile = $replace(%mfile,\\,\) }
if (%desc != $null) && (%duration != $null) { %ext = 1 }
if (%desc == $null) { var %desc = $nopath(%mfile),%desc = $gettok(%desc,1- [ $calc($numtok(%desc,46) - 1) ] ,46) }
if (%duration isnum) { %duration = $_aircamp.duration(%duration,1) }
else { %duration = ?? }
did -a %d 2103 %mfile $+ " $+ $nopath(%mfile) $+ " $+ %ext $+ " $+ %duration $+ "0"0" $+ %desc
if (%duration != ??) { did -a %d 2102 %desc ( $+ %duration $+ ) }
else { did -a %d 2102 %desc }
var %mfile,%duration,%desc,%ext = 0
}
else {
error.a Invalid playlist file: ' $+ %f $+ '
break
}
inc %i
}
}
else { error.a Invalid playlist file: ' $+ %f $+ ' }
}
else {
var %k = $iif($_list.get(mp3dirs,1) != $null,$_list.get(mp3dirs,1),$mp3dir) $+ *.m3u,%f = $$dir="Save playlist" %k,%win = @__aircampsavelist,%text
if ($dialog(%d) == $null) { return }
if (*.m3u !iswm %f) { %f = %f $+ .m3u }
dialog -v %d
if ($isfile(%f)) && ($_not($_filexists(0,aIRCamp - Save Playlist,%f))) { }
if (*.m3u !iswm %f) || ($dialog(%d) == $null) { return }
_openwins %win
aline %win #EXTM3U
var %i = 1,%n = $did(%d,2103).lines
while (%i <= %n) {
%text = $did(%d,2103,%i)
if ($gettok(%text,3,34)) { aline %win #EXTINF: $+ $gettok(%text,4,34) $+ , $+ $gettok(%text,7-,34) }
aline %win $gettok(%text,1,34)
inc %i
}
savebuf %win " $+ %f $+ "
close -@ %win
}
}
alias _aircamp.dialog.win2playlist {
var %d = _aircamp,%win = $1,%flags = $2
if ($dialog(%d) == $null) || ($window(%win) == $null) { return }
_aircamp.clearplaylist
var %i = 1,%n = $line(%win,0),%line
while (%i <= %n) {
var %line = $line(%win,%i),%desc = $gettok(%line,7-,34),%duration = $gettok(%line,4,34)
did -a %d 2103 %line
if (%duration != ??) { did $iif(c isin %flags,-ack,-a) %d 2102 %desc ( $+ %duration $+ ) }
else { did $iif(c isin %flags,-ack,-a) %d 2102 %desc }
inc %i
}
did -z %d 2102
close -@ %win
}
alias _aircamp.moveup {
if ($dialog(_aircamp) == $null) { return }
var %i = 1,%m,%t
while ($did(_aircamp,2102,%i).sel != $null) {
%m = $ifmatch
if (%m > 1) && ($_not($did(_aircamp,2102,$calc(%m - 1)).state)) {
%t = $did(_aircamp,2102,%m)
did -d _aircamp 2102 %m
did -ick _aircamp 2102 $calc(%m - 1) %t
%t = $did(_aircamp,2103,%m)
did -d _aircamp 2103 %m
did -ick _aircamp 2103 $calc(%m - 1) %t
}
inc %i
}
}
alias _aircamp.movedown {
if ($dialog(_aircamp) == $null) { return }
var %l = $did(_aircamp,2102).lines,%i = $did(_aircamp,2102,0).sel,%m,%t
while (%i) && ($did(_aircamp,2102,%i).sel != $null) {
%m = $ifmatch
if (%m < %l) && ($_not($did(_aircamp,2102,$calc(%m + 1)).state)) {
%t = $did(_aircamp,2102,%m)
did -d _aircamp 2102 %m
did -ick _aircamp 2102 $calc(%m + 1) %t
%t = $did(_aircamp,2103,%m)
did -d _aircamp 2103 %m
did -ick _aircamp 2103 $calc(%m + 1) %t
}
dec %i
}
}
alias _aircamp.addfile {
var %d = _aircamp,%dirfile = $1-,%file = $nopath(%dirfile),%wm = %dirfile $+ "*,%hash = __aircamphashtmp,%z,%duration,%desc,%ext = 0
if ($isfile(%dirfile) == $false) { return }
if ($didwm(%d,2103,%wm,0) == 0) {
%desc = $gettok(%file,1- [ $calc($numtok(%file,46) - 1) ] ,46)
if ($did(%d,2111).state) {
var %ext = 1,%z = $_mp3info(%dirfile,<LENGTH><ARTIST><TITLE>,%hash),%duration = $hget(%hash,length),%desc = $hget(%hash,artist) - $hget(%hash,title)
hfree %hash
}
if (%duration isnum) { %duration = $_aircamp.duration(%duration,0) }
else { %duration = ?? }
did -a %d 2103 %dirfile $+ " $+ %file $+ " $+ %ext $+ " $+ %duration $+ "0"0" $+ %desc
if (%duration != ??) { did -a %d 2102 %desc ( $+ %duration $+ ) }
else { did -a %d 2102 %desc }
did -z %d 2102
}
}
; /_mp3.play -flags file
; flags: s - from start
; r - resume (if possible), else from start
; v - play only if currently playing
; t - remotely requested
alias _mp3.play {
var %d = _aircamp,%flags = $1,%file = $2-,%h = _aircamphtmp,%start = 1,%wm,%line,%desc,%duration,%playing = 1,%tmptags,%mute = 0,%playpos = 0,%tmplocal = $strip($_mp3.format.local),%tmpremote = $strip($_mp3.format.remote)
if ($dialog(%d)) {
did -o %d 1092 1 %file
%mute = $did(%d,1048).state
}
%wm = %file $+ "*
if (*.mp3 !iswm %file) || ($isfile(%file) == $false) {
if ($dialog(%d)) && ($didwm(%d,2103,%wm,1)) { did -c %d 2102 $ifmatch }
.timer_aIRCmpprevnext -o 1 1 _aircamp.prevnext + 1
return
}
%tmptags = <KBPS><kHZ><MODE><ARTIST><TITLE>
if (<album> isin %tmplocal) || (<album> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<year> isin %tmplocal) || (<year> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<comment> isin %tmplocal) || (<comment> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<genre> isin %tmplocal) || (<genre> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<track> isin %tmplocal) || (<track> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<duration> isin %tmplocal) || (<duration> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<version> isin %tmplocal) || (<version> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<bitrate> isin %tmplocal) || (<bitrate> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<variable> isin %tmplocal) || (<variable> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<sample> isin %tmplocal) || (<sample> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<copyright> isin %tmplocal) || (<copyright> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<private> isin %tmplocal) || (<private> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<crc> isin %tmplocal) || (<crc> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
if (<filesize> isin %tmplocal) || (<filesize> isin %tmpremote) { %tmptags = %tmptags $+ $ifmatch }
%tmptags = %tmptags $+ <length>
_setsetup mp3 aircamp.lastsong %file
_dummy $_mp3info(%file,%tmptags,%h)
if ($dialog(%d)) {
did -o %d 1003 1 $hget(%h,bitrate) $+ kbps/ $+ $hget(%h,khz) $+ khz/ $+ $hget(%h,mode)
%desc = $hget(%h,artist) - $hget(%h,title)
if ($didwm(%d,2103,%wm,1)) {
%line = $ifmatch
%duration = $hget(%h,length)
if (%duration isnum) { %duration = $_aircamp.duration(%duration,0) }
else { %duration = ?? }
did -o %d 2103 %line $gettok($did(%d,2103,%line),1-2,34) $+ "1" $+ %duration $+ "0"0" $+ %desc
if (%duration != ??) {
did -oc %d 2102 %line %desc ( $+ %duration $+ )
did -o %d 1002,2002 1 %desc ( $+ %duration $+ )
}
else {
did -oc %d 2102 %line %desc
did -o %d 1002,2002 1 %desc
}
}
else { did -o %d 1002,2002 1 %desc }
dialog -t %d aIRCamp: %desc
}
if ($inwave) { splay -w stop }
if (r isin %flags) && ($_mp3.inmp3.fname == %file) {
if (%mute == 0) {
if ($inmp3) { splay -p resume }
elseif ($_ampdll.status == OK paused) { _ampdll.Unpause }
}
if ($dialog(%d)) { %playpos = $did(%d,2980,2) }
}
elseif (s isin %flags) || (r isin %flags) || ((v isin %flags) && (($_mp3.inmp3) || ($did(%d,2980,1)))) {
if (%mute == 0) {
if ($_sound.aretherequiredwinampdllsloadedtoplaymymetallicamp3s?) {
if ($_mp3.inmp3.fname) { _ampdll.stop }
_ampdll.Play %file
}
else { splay -p " $+ %file $+ " }
}
_mp3.ad_on_play %file
%playpos = 0
}
else {
mp3 stop
%playing = 0
}
if ($dialog(%d)) {
did -u %d 1043,2043
if (%playing) {
did -o %d 2980 1 1
did -o %d 2980 2 %playpos
did -o %d 2980 3 $hget(%h,LENGTH)
did -o %d 2980 4 0
}
}
hfree %h
_aircamp.timer +n
}