Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (2) </ [1] 2 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: web based volume control, control aumix via webpage< Next Oldest | Next Newest >
spark-o-matic Offline





Group: Members
Posts: 68
Joined: Jan. 2008
Posted: Nov. 16 2008,19:40 QUOTE

Morning all,

I use my DSL/Apache computer and xmms to play music.  Aumix works great but it's a pain to run to that computer to change volume or log in on ssh all the time.  So I spent last night and this morning working on this little bit of code to set volumes from a web page.

This is the part written in PERL.
Code Sample
#!/usr/bin/perl

$cmd="aumix";
@validappend=('w',
'v',
'l',
'i'
);


$postcmd="aumix -q >aumix.html";

if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
} else {
print "Content-Type: text/html\n\n";
print "ERROR READING FORM DATA\n\n";
exit;
}
foreach $pair (@pairs) {
local($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
if ($data{$name} && $value) { $data{$name} = "$data{$name}, $value"; }
elsif ($value) {
push(@Field_Order,$name);
$data{$name} = $value;
}}

$nappend=@validappend;
for ($cc0=0;$cc0<=$nappend;$cc0++) {
if ($data{$validappend[$cc0]}) {
$cmd="$cmd \-$validappend[$cc0] $data{$validappend[$cc0]}";
}

}
$ti=time();  


system "$cmd";

system "$postcmd";

print "location: aumix.html?$ti\n\n";

exit;


This is an example of what you might include in an html page.
Code Sample
MASTER VOLUME
<a href="aumix.cgi?v=1" target="plist">MUTE</a>
<a href="aumix.cgi?v=-1" target="plist">-1</a>
<a href="aumix.cgi?v=-3" target="plist">-3</a>
<a href="aumix.cgi?v=-7" target="plist">-7</a>
<a href="aumix.cgi?v=80" target="plist">80</a>
<a href="aumix.cgi?v=95" target="plist">95</a>
<a href="aumix.cgi?v=%2b7" target="plist">+7</a>
<a href="aumix.cgi?v=%2b3" target="plist">+3</a>
<a href="aumix.cgi?v=%2b1" target="plist">+1</a><br>
PCM WAVE
<a href="aumix.cgi?w=1" target="plist">MUTE</a>
<a href="aumix.cgi?w=-1" target="plist">-1</a>
<a href="aumix.cgi?w=-3" target="plist">-3</a>
<a href="aumix.cgi?w=-7" target="plist">-7</a>
<a href="aumix.cgi?w=35" target="plist">35</a>
<a href="aumix.cgi?w=50" target="plist">50</a>
<a href="aumix.cgi?w=85" target="plist">85</a>
<a href="aumix.cgi?w=99" target="plist">99</a>
<a href="aumix.cgi?w=%2b7" target="plist">+7</a>
<a href="aumix.cgi?w=%2b3" target="plist">+3</a>
<a href="aumix.cgi?w=%2b1" target="plist">+1</a><br>
<a href="aumix.cgi?w=55&v=80" target="plist">low</a>
<a href="aumix.cgi?w=85&v=80" target="plist">high</a>
<a href="aumix.cgi?w=95&v=95" target="plist">Crank It Up!!</a>
<br>

This also works directly typing in something like
Code Sample
http://192.168.1.2/aumix.cgi?v=80&w=75
which sets volume to 80 and pcm to 75.I designed this to use two frames and work without Java.  aumix -q shows up in the second frame.  I wrote it to be flexible and at least a little secure.  By changing the values of $cmd and @validappend I suppose most any command can be executed but they also limit what can be done.  $postcmd will change what shows up on the html page.  I used html because I am going to be doing more with this in the grander scheme of things.  It displays better as a txt and thats easy enough by changing the file name in two places.  

I have only tested this with the Apache extention.  If someone gets it working with Monkey I'd be interested to know.


--------------
The smartest person is not the person who knows the most.  
The smartest person is the one who knows which book to look in.
Community knowledge can be the sum of it's knowledge or the sum of it's ignorance
The Definition of a 'Brain Fart':
When something comes out of my brain that Stinks!
Back to top
Profile PM WEB 
chaostic Offline





Group: Members
Posts: 328
Joined: Mar. 2005
Posted: Nov. 16 2008,21:45 QUOTE

You mean you don't have a constant ssh session with your linux box? :p

It could probably be done through PHP to work with monkey.

http://www.php-mysql-tutorial.com/qna....and.php

So just a php script with just a bunch of
system('/full/path/to/aumix options > /dev/null 2>&1; /full/path/to/aumix -q')
and a way to select them.
Back to top
Profile PM 
spark-o-matic Offline





Group: Members
Posts: 68
Joined: Jan. 2008
Posted: Nov. 17 2008,03:39 QUOTE

Quote
It could probably be done through PHP to work with monkey.

I have done a very little with PERL/CGI under Monkey and it is supported but the problem I had was following simbolic links

As far as PHP I guess that turns into a bit of a phyilosophical discussion.  It is not so much that PHP has a lot of security flaws but PHP has become so popular amongst programmers with no talent or skill what-so-ever and no concern for security that it is developing a reputation of not being secure.  I mean, who would write a program that would write to itself or ever set permitions that the program could write to itself?  Who do you know who doesn't call themselves a 'programmer'?  I realize that ASP was Microsoft and PHP is not but I would like to see a language stick around for as long as Perl, HTML or c before I learn its intricacies.  Since I sat down in front of my first computer in 1982 I have become fluent in 9 languages (most of which are obsolite) and conversational in many others (many obsolite now).  I have been writing PERL to run on web servers for a decade now and I realy can't see it not being available to me in the near future.  The actual techniques havn't changed much over the years, its just a matter of learning a new set of comands and syntax which is time consuming.  For me, for now, a DWIM (do what I mean) language works for me as long as I know what I mean to do.. :p   The other perk for me is how heavily PERL is based on Linux.  I don't know how many times I have pressed the 'du' button when I realized that what I did with PERL was exactly what I needed to do with Linux.  Boy I guess I'm getting a bit  :O  but when someting just works, that works for me.

thanks all

edit:
Quote
You mean you don't have a constant ssh session with your linux box?
Only 1 Linux box? Of the 6 computers I use consistantly, only 1 still has Win98SE as part of a muti-boot.  It gets used less then once a month and only for a very few things I use rarely that I havn't learned to do under Linux in less then a year!


--------------
The smartest person is not the person who knows the most.  
The smartest person is the one who knows which book to look in.
Community knowledge can be the sum of it's knowledge or the sum of it's ignorance
The Definition of a 'Brain Fart':
When something comes out of my brain that Stinks!
Back to top
Profile PM WEB 
curaga Offline





Group: Members
Posts: 2163
Joined: Feb. 2007
Posted: Nov. 17 2008,14:23 QUOTE

What, ssh? I only do that to my headless boxes, all the others have their own screens :D

--------------
There's no such thing as life. Those mean little jocks invented it ;)
-
Windows is not a virus. A virus does something!
Back to top
Profile PM 
stunix*com Offline





Group: Members
Posts: 64
Joined: July 2006
Posted: Nov. 20 2008,23:57 QUOTE

i have a dsl thinkpad wired directly to a poweramp and control volume and selection using a 600x480 vnc server, the box also runs edna to serve any other machine from my TB usb drive.  it works for me, the vncclient can be configured to open from a menu or icon and just as easy as a webpage would.
if all fails i can open the thinkpads screen.

this solution has pushed me in to putting my Linn LP12, Revox R77 and Teac Transport and DAC in to storage, the wife has happily taken over the space with pictures of my nephew.
Back to top
Profile PM 
7 replies since Nov. 16 2008,19:40 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (2) </ [1] 2 >/
reply to topic new topic new poll
Quick Reply: web based volume control

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code