Training, Open Source computer languages

This is page http://www.wellho.net/forum/Perl-Programming/Playing- ... -site.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Playing Wav/Mp3s when users visit my Perl site

Posted by anthonysaulnier (anthonysaulnier), 10 April 2005
Good day, I am trying to set up my web site in using Perl on a Red Hat 9.0 Apache 2.0 server so that when people visit my web site a wav or mp3 file will play.  I have tried all sorts of things such as installing and using use Audio::Wav; but I have not had any luck what-so-ever .  I have even tried using the HTML embed tags, but still no go.  

I am using Perl and CGI scripting combined on the site and my site seems to work fine otherwise.  

I was just wondering if anyone has any ideas on how I could set up my site to play wav files or knows where I can get good examples of code.


Anthony

Posted by admin (Graham Ellis), 10 April 2005
I'm not a great fan of sound on web sites ... so it's not something I've played with much.  But I thought you could just embed sounds into a web site in much the same way you can embed images - I've just visited a Nursery Rhyme site and found

<bgsound src="midi/blacksheep.mid" loop="-1">

used to bring up the sound.  I don't think you need Perl at all (??) - although you could usefully use it to manage and perhaps convert the sound file(s).

Posted by anthonysaulnier (anthonysaulnier), 10 April 2005
HI Graham, thank you for your reply, I did try your suggestion but it does not seem to work for my perl/cgi script although I am sure that it would work great in the htdocs dir using html.

I am still trying to think of some ideas such as framing pages, put 1 html page with teh sounds together with my cgi page.



Anthony

Posted by admin (Graham Ellis), 10 April 2005
I've had a play / written a test program at http://www.wellho.net/cgi-bin/demo/trainsounds.pl.   Have play ... see if you can get anything from it.

Source code:

Code:
#!/usr/bin/perl

print "content-type: text/html\n\n";

@sounds = (
       "City of Truro on Lapworth Bank","http://www.vintagetrains.co.uk/sound/3440_lapworth.wav",
       "City of Truro at Barton Bridge","http://www.vintagetrains.co.uk/sound/3440_barton_bridge.mp3",
       "Silvertown and Durango narrow gauge railroad","http://www.naturesongs.com/recordists/durango1.mp3",
       "Yellowmargined Flycatcher","http://www.naturesongs.com/ymfl1.wav",
       "Surf at La Jolla","http://www.naturesongs.com/surf1.mp3",
       "Black bellied Whistling duck","http://www.naturesongs.com/bbwd2.wav");

$soundwanted = time()%(@sounds/2);

$whichone = $sounds[$soundwanted*2];
$soundurl = $sounds[$soundwanted*2+1];

$listing = "";
for ($k=0; $k<@sounds; $k+=2) {
       $listing .= "<li><a href=".$sounds[$k+1]." target=noisywindow>$sounds[$k]</a> at ".$sounds[$k+1];
       }

# Following line added in to header causes immediate refresh to a sound.
# Another alternative is CSS2 ... if you have browser support
# <meta http-equiv=Refresh content="0; URL=$soundurl">

print <<"HTML";
<html>
<head><title>Sound Demonstration $whichone</title></head>
<bgsound src="$soundurl" loop="-1">
<body bgcolor=#FFFFCC><h1>Sound Demonstration</h1>
According to "HTML and XHTML, the definitive guide", the bgsource attribute to provide sound
integrated more cleanly into pages than other methods such as object and embed tags, but it's
Internet Explorer only.  This page has a bgsound attribute and you should be hearing
<b>$whichone</b> if your browser supports it.<br><br>.You might also be able to sound by following
the links below that will load them in separate pages.<br><ul>$listing</ul><br>
All sounds linked to by this page are located at the sites mentioned in the URLs above and you
should check the copyright statements at those sites for condtions of use. We've just provided
the links
</body>
</html>
HTML


Posted by ed (ed), 19 April 2005
You could always embed a little flash file that plays an mp3 into the HTML. Flash does quite a good job of compressing mp3s so that the filesize is small.







This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho