Sunday, 15 May 2011

html - How to detect browser type in HTML5 or Javascript for playing mp3 instead of webm in Safari/IE browsers? -



html - How to detect browser type in HTML5 or Javascript for playing mp3 instead of webm in Safari/IE browsers? -

i have created survey in qualtrics wherein play webm audios. in safari webm doesn't play , ie user needs install this google plugin. wondering if there code in preferably html(5) or javascript can observe type of browser , if it's safari or ie play mp3 version of audio(which have on server well). please allow me know if there improve solutions tackling problem of playing sound in various browsers.

the sec auditory story titled, &ldquo;the precious possession.&rdquo; press &ldquo;play story&rdquo; button begin listening story; after have finished listening story, reply set of questions story. <div> <audio controls="" id="audio3" style="display:none"><source src="http://langcomplab.net/most_precious_possession_master.webm" style="width:50%" type="audio/webm" />your browser doesn&#39;t back upwards sound format.</audio> </div> <p>&nbsp;</p> <div><button name="play" onclick="disabled=true" style="height:25px; width:200px" type="button">play story</button></div>

here's javascript in qualtrics means cannot alter much.

qualtrics.surveyengine.addonload(function() { /*place javascript below line*/ var aud = document.getelementbyid('audio3'); this.questionclick = function(event,element){ if((element.type == "button") && (element.name == "play")) { aud.play(); } } });

if provide both mp3 , webm sources , set type attribute properly, browser can select 1 supports. add together mp3 one. set mp3 1 first since old safari browsers utilize first 1 (and supported mp3), otherwise browsers select first 1 can back upwards based on type.

<audio controls="" id="audio3" style="display:none"> <source src="http://langcomplab.net/most_precious_possession_master.mp3" style="width:50%" type="audio/mp3" /> <source src="http://langcomplab.net/most_precious_possession_master.webm" style="width:50%" type="audio/webm" /> browser doesn&#39;t back upwards sound format. </audio>

see additional info on mdn applies both sound , video.

https://developer.mozilla.org/en-us/docs/web/guide/html/using_html5_audio_and_video

javascript html html5 audio safari

No comments:

Post a Comment