[Seaside] How to best detect browser for audio tag differences
johan at inceptive.be
Wed Aug 4 09:54:37 UTC 2010
In particular, the section on html5 audio formats: http://www.modernizr.com/docs/#audioformats
Modernizr detects the abilities of your browser w.r.t. html5.
On 03 Aug 2010, at 01:48, Tim Mackinnon wrote:
> 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' ].
> form: [
> (html button)
> onClick: ((html jQuery id: 'noise') each: (JSStream this call: 'play'));
> with: 'Do It'.
> seaside mailing list
> seaside at lists.squeakfoundation.org
More information about the seaside