Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #17791

html5 Audio

From 123Jim <jnkjnjnini@uhnuhnunuhnuy.invalid>
Newsgroups comp.lang.javascript
Subject html5 Audio
Date 2012-12-21 23:41 +0000
Organization A noiseless patient Spider
Message-ID <kb2s2r$ihs$1@dont-email.me> (permalink)

Show all headers | View raw


Q: Is the html5 Audio code below cross browser and robust? It occurs to 
me that if the browser does not like 'canplaytype' but nevertheless 
needs ogg, not MP3 then it will fail (I've tested in the newest versions 
of IE, Firefox, Opera and Chrome with no problems)

var audio1 = new Audio();

if (!!audio1.canPlayType && audio1.canPlayType('audio/ogg; 
codecs="vorbis"') != "") {
	//alert('ogg sounds');
	var	click1snd = new Audio("click1.ogg");
	var	incorrectsnd = new Audio("incorrect.ogg");
	var	correctsnd = new Audio("correct.ogg");
}else{
	//alert('mp3 sounds');
	var	click1snd = new Audio("click1.mp3");
	var	incorrectsnd = new Audio("incorrect.mp3");
	var	correctsnd = new Audio("correct.mp3");
}

	click1snd.play();

My webpage: 
http://myweb.tiscali.co.uk/ladycroft/webdevfun/problem_solving.html

.... and here's the original source I modified:
http://html5doctor.com/html5-audio-the-state-of-play/

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

html5 Audio 123Jim <jnkjnjnini@uhnuhnunuhnuy.invalid> - 2012-12-21 23:41 +0000
  Re: html5 Audio Andrew Poulos <ap_prog@hotmail.com> - 2012-12-22 11:46 +1100
    Re: html5 Audio 123Jim <jnkjnjnini@uhnuhnunuhnuy.invalid> - 2012-12-22 13:31 +0000
      Re: html5 Audio 123Jim <jnkjnjnini@uhnuhnunuhnuy.invalid> - 2012-12-22 16:33 +0000
        Re: html5 Audio 123Jim <jnkjnjnini@uhnuhnunuhnuy.invalid> - 2012-12-22 23:16 +0000
          Re: html5 Audio David Mark <dmark.cinsoft@gmail.com> - 2013-01-05 17:54 -0800
            Re: html5 Audio David Mark <dmark.cinsoft@gmail.com> - 2013-01-05 18:06 -0800
            Re: html5 Audio David Mark <dmark.cinsoft@gmail.com> - 2013-01-05 23:18 -0800

csiph-web