You are probably trying to play an unsupported format :)
Firefox 3.6 doesn't support mp3. You can use audioEl.canPlayType() to
detect the available formats like so:
[... snip ...]
AudioElement audioEl = audio.getAudioElement();
audioEl.setAutoplay(true);
if (!audioEl.canPlayType("audio/mpeg;").equals(audioEl.CANNOT_PLAY))
{
audioEl.setSrc("smallmp3.mp3");
} else if (!audioEl.canPlayType("audio/ogg; codecs=\"vorbis
\"").equals(audioEl.CANNOT_PLAY)) {
audioEl.setSrc("smallogg.ogg");
} else {
RootPanel.get().add(new Label("no available media types"));
}
audioEl.setControls(true);
audioEl.setLoop(false);
audioEl.setVolume(1.0);
RootPanel.get().add(audio);
} else {
RootPanel.get().add(new Label("audio not supported"));
}
[... snip ...]
Philip
On Mar 3, 2:53 pm, "Armishev, Sergey" <[email protected]> wrote:
> Thank you for the quick answer. When I moved forward with pure GWT based
> approach I found that Audio object works on Chrome but not on Firefox
> (3.6.13). Am I doing something wrong or it is some limitations? Below the
> code. I made audio controls visible and actually see them on Chrome as well
> as hear the sound but the same code doesn't show any audio player on Firefox.
> I tested only in development mode. Here is the code
> com.google.gwt.media.client.Audio audio =
> com.google.gwt.media.client.Audio.createIfSupported();
> if(audio != null) {
> com.google.gwt.dom.client.AudioElement audioEl =
> audio.getAudioElement();
> audioEl.setAutoplay(true);
> audioEl.setSrc(fullURL);
> audioEl.setAutoplay(true);
> audioEl.setControls(true);
> audioEl.setLoop(false);
> audioEl.setVolume(1.0);
> RootPanel.get().add(audio);
> } else {
> //no HTML5 audio support
> }
>
>
>
>
>
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Julien Dramaix
> Sent: Thursday, March 03, 2011 8:13 AM
> To: Google Web Toolkit
> Subject: Re: howto check HTML5 audio tag supported in a browser
>
> gwtmodernizr can help you to detect browser support for HTML5 and CSS3
> features
>
> Check at :http://code.google.com/p/gwtmodernizr/
>
> On Mar 3, 12:31 am, John LaBanca <[email protected]> wrote:
> > GWT has an Audio widget for HTML5 audio support:
> > com.google.gwt.media.client.Audio.isSupported()
>
> > Thanks,
> > John LaBanca
> > [email protected]
>
> > On Wed, Mar 2, 2011 at 6:29 PM, Armishev, Sergey
> > <[email protected]>wrote:
>
> > > I am new to HTML5 and have this simple question: what is the best way to
> > > check that HTML5 <audio> tag is supported on the browser? In general I
> > > would
> > > like to be able to check for all/most of HTML5 tags. The only library I
> > > found is Modernizr fromhttp://diveintohtml5.org/detectbutit doesn't
> > > check for <audio> . Anybody knows and can recommend other libraries? Any
> > > GWT
> > > based libraries?
>
> > > -Sergey
>
> > > _____________________________________________________
> > > This electronic message and any files transmitted with it contains
> > > information from iDirect, which may be privileged, proprietary
> > > and/or confidential. It is intended solely for the use of the individual
> > > or entity to whom they are addressed. If you are not the original
> > > recipient or the person responsible for delivering the email to the
> > > intended recipient, be advised that you have received this email
> > > in error, and that any use, dissemination, forwarding, printing, or
> > > copying of this email is strictly prohibited. If you received this email
> > > in error, please delete it and immediately notify the sender.
> > > _____________________________________________________
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Google Web Toolkit" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-web-toolkit?hl=en.-Hide quoted text -
>
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group
> athttp://groups.google.com/group/google-web-toolkit?hl=en.
>
> </PRE><BR><span
> style='font-size:8.0pt;font-family:"Arial","sans-serif";color:#003366'>
> _____________________________________________________<BR>
> This electronic message and any files transmitted with it contains<BR>
> information from iDirect, which may be privileged, proprietary<BR>
> and/or confidential. It is intended solely for the use of the individual<BR>
> or entity to whom they are addressed. If you are not the original<BR>
> recipient or the person responsible for delivering the email to the<BR>
> intended recipient, be advised that you have received this email<BR>
> in error, and that any use, dissemination, forwarding, printing, or<BR>
> copying of this email is strictly prohibited. If you received this email<BR>
> in error, please delete it and immediately notify the sender.<BR>
> _____________________________________________________
> </SPAN><PRE>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.