Page 1 of 1

Wavs in Php

Posted: Wed May 19, 2004 6:49 pm
by Kon-Tiki
Is there a way to play wavs in php?

Re:Wavs in Php

Posted: Wed May 19, 2004 8:51 pm
by AGI1122
PHP is server side... so no. It would require you to place an embeded object in the html though.

Re:Wavs in Php

Posted: Wed May 19, 2004 9:09 pm
by Kon-Tiki
Fair 'nuff :)

Re:Wavs in Php

Posted: Thu May 20, 2004 4:01 pm
by Kon-Tiki
>_> <_< >_>
Just realized I know absolutely nothing 'bout the object-tag and W3schools isn't clear on how to play wavs through it.

Code: Select all

echo "<object>scheten/scheet$random.wav</object>";
That's the line of code I have at the moment, but all it does, is show
/scheten/scheet6.wav
or any other number instead of 6 on the screen.

Edit: Ok, found it out. <embed>... but that didn't accept the variable in the sourcefiles. Temporarily worked around that with a switch.

Re:Wavs in Php

Posted: Fri May 21, 2004 7:03 am
by Candy
Kon-Tiki wrote:

Code: Select all

echo "<object>scheten/scheet$random.wav</object>";
Edit: Ok, found it out. <embed>... but that didn't accept the variable in the sourcefiles. Temporarily worked around that with a switch.
Just a guess, but I've heard IE is the only browser that doesn't know object. Do you use IE, and if so, would you consider switching?

Re:Wavs in Php

Posted: Fri May 21, 2004 8:35 am
by AGI1122
Actually it's netscape that doesn't support it. IE has supported it since 3.0.

Re:Wavs in Php

Posted: Fri May 21, 2004 8:39 am
by Kon-Tiki
I've used echo '<embed src="scheten/scheet1.wav" autostart=TRUE hidden=TRUE>'; in combination with a switch-command for the randomizing, since embed doesn't seem to accept scheten/scheet$random.wav. It's tested in IE, Opera, Firefox, Mozilla and Mozilla Firebird and only the Mozillas weren't able to run it properly -> No sound.

Re:Wavs in Php

Posted: Fri May 21, 2004 9:29 am
by Candy
Kon-Tiki wrote: I've used echo '<embed src="scheten/scheet1.wav" autostart=TRUE hidden=TRUE>'; in combination with a switch-command for the randomizing, since embed doesn't seem to accept scheten/scheet$random.wav. It's tested in IE, Opera, Firefox, Mozilla and Mozilla Firebird and only the Mozillas weren't able to run it properly -> No sound.
As far as the standard HTML language is concerned, EMBED is nothing. The only tag that allows objects is object, as seen at http://www.w3.org/TR/html4/struct/objects.html#h-13.3

I expect the sound to work in the mozilla's when you use object, and I expect it not to work in old (pre-6) netscapes.

You do note that Firefox, Firebird and Mozilla are all three of the Mozilla project? You also note that Netscape 6+ also uses the Mozilla codebase?

As a last note, I would recommend you to use standard tags, so it will not just work on whatever may be around today, but also what is around tomorrow. Deviating from a standard should only be done when it's in the interest of progress (IE: if the standard is really old).

PS: doesn't Moz have some form of a fartfilter that filters out all bad sounds? ;)

PS2: can't you turn it off? :D

Re:Wavs in Php

Posted: Fri May 21, 2004 11:16 am
by Kon-Tiki
All things are standard, and those browsers those browsers I mentioned that it works in and where it doesn't work in have been listed through testing, not through reasoning. You can say what you want 'bout those browsers, but if my brother can't get it to work in Mozilla and Mozilla Firebird, but Strangequark can get it to work in Firefox, I know it won't work under Mozilla and Mozilla Firebird but that it will under Firefox :P

Anyway, got rid of the switch-command after Eero explained me why it didn't accept the var in the name and got it to work now. 75 lines of code (and three more for each file I'd add) into one :)

Another optimalisation of the code turns out to be a pain.

Code: Select all

$amount = scandir('scheten/');
$count = count($amount);
Doesn't matter if I put 'scheten', "scheten", $dir = 'scheten'; scandir($dir); or anything like that in there, I keep getting this error message:
Fatal error: Call to undefined function: scandir() in /home/raf/public_html/rommel/projectJFF.php on line 12
I don't see what I did wrong or how to solve it. Leaving it out'd have me change the code (the max number in the randomizer a bit below) each time I add a file to scheten/, which rather sucks to have to do that.

Re:Wavs in Php

Posted: Fri May 21, 2004 5:19 pm
by butterfly

Re:Wavs in Php

Posted: Fri May 21, 2004 10:09 pm
by AGI1122
I modified your post butterfly it was stretching the topic out. I made the link show some text instead of the full url.

Anyway, that error means that either you didn't make a createdir function... or your using a php version that doesn't have it compiled into it.