• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to play an audio in JSF 2?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I have a JSF page and wants to display an audio file.



The "test.wav" file is under my /src/main/webapp/resources/audio/test.wav. However, in browser, I can't see any sign of the audio file. I want to click it in browser and hear the sound. Also, in my Eclipse editor, there is a yellow warning message in this line, indicating "unknown tag (audio)".
What's the right way to play an audio in a JSF file?

 
Saloon Keeper
Posts: 28654
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSF doesn't have any built-in audio support. However, I think PrimeFaces may have a multi-media tag that can do it.
 
marlon min
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It turns out that I can use HTML5 tag:

<audio controls="x">
<source src="resources/audio/test.wav" type="audio/wav" />
</audio>

But it still reminds me in the Eclipse editor that the tag is "unknown". However, it can display the audio control and I can play.

Is that because my page above is an mixture of JSF and HTML5? HTML5 can be mixed together with JSF 2? Thanks.
 
Tim Holloway
Saloon Keeper
Posts: 28654
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I don't encourage mixing HTML tags with JSF tags. But sometimes it's unavoidable. And sometimes it's avoidable, but too much trouble.

I think you can PROBABLY make Eclipse happy if you add an XSD schema declaration for HTML5 to your view template.
 
marlon min
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to define such aa XSD schema and where to put it?

Tim Holloway wrote:Well, I don't encourage mixing HTML tags with JSF tags. But sometimes it's unavoidable. And sometimes it's avoidable, but too much trouble.

I think you can PROBABLY make Eclipse happy if you add an XSD schema declaration for HTML5 to your view template.

 
marlon min
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Although the following HTML5 tag works in my JSF page, why does it remind me that "audio" is an unknown tag? There is a yellow flag that indicates it's an invalid tag. I am developing in Eclipse. Thanks.

 
Tim Holloway
Saloon Keeper
Posts: 28654
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the Eclipse editor checking your XML/HTML. To make it stop complaining, you have to attach an XSD namespace (schema) to your document and you have to have it registered with Eclipse, so that the Eclipse XML verifier can apply the rules in that schema to properly validate the document.

This is not a JSF issue, it's strictly a problem with Eclipse. If you want more information, you'll need to ask in the Eclipse (IDEs and Version Control) forum, and it's best to ask as an XML/HTML question, because it literally has nothing to do with JSF beyond the fact that the JSF View Template Language is XML-based.

Personally, I find the process of getting Eclipse to adopt new XML schemas more frustrating than it ought to be, and usually I find it easier to ignore the little yellow boxes than to spend the time and effort needed to shut it up. It's the little red boxes I worry about.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic