[Seaside] How to best detect browser for audio tag differences
Tim Mackinnon
tamackinnon at gmail.com
Mon Aug 2 23:48:16 UTC 2010
Hi guys - I've looked through suggestions for browser detection on the
list - but am unsure what the best approach is to handle the
differences between how browsers handle the audio tag in html5.
I don't need to support all browsers (and part of this is education
for me) - but I particularly notice that Firefox supports ogg and wav
media while safari supports mp3 (damn those committees).
My best attempt so far is below - but I wonder if this is the best way
to go about it (is there a better way of detecting a browser type? I
saw that jQuery has something - is it better to use it - and do
something on a page load script to set the src attribute of a single
audio tag?).
myRequest := self requestContext request. "for debugging - but
confused the hell out of me that I needed a variable"
(myRequest userAgent beginsWith: 'Mozilla')
ifTrue: [
(html audio)
url: (MyLibrary default urlForFile: 'sound.wav');
id: 'noise' ]
ifFalse: [
(html audio)
url: (MyLibrary default urlForFile: 'sound.mp3');
type: 'audio/mpeg';
id: 'noise' ].
html
form: [
(html button)
onClick: ((html jQuery id: 'noise') each: (JSStream this call:
'play'));
with: 'Do It'.
].
thanks,
Tim
More information about the seaside
mailing list