Table of Contents


The microphone component allows the developer to capture sound using a device's audio input/microphone, and then upload the audio file to the server to be processed or shared with other users or facets of an application. For a desktop browser, a file upload button will allow the user to select an audio file on their local file system which can then be uploaded and shared in a similar manner. Must denote form as multipart if using a desktop browser, or use the uploadhelper component as seen in example markup below.


An embedded container supported by ICEfaces mobility, must be present in order to use this component for capturing actual video. The desktop browser will allow users to select files to be uploaded for use in the application.

Basic use with no user parameters

Typically, you will want to use the container upload button.

<h:form >
   <mobi:microphone id="mic_one" value="#{micBean.audioClip}"/>
   <mobi:commandButton type="button"

The Map object is value bound to a backing bean and the File and contentType can be extracted from the Map in the backing bean.

public void setAudioClip(Map audioMap){
    this.audioClip = audioMap;
    File audioFile = (File)audioMap.get("file");
    String contentType = (String)audioMap.get("contentType");
    //you can use these objects to listen to the clip with mobi:audio

Can use attribute maxtime to limit the duration of the audio clip

<h:form enctype="multipart/form-data" >
   <mobi:microphone id="mic_two"
       value="#{micBean.audioClip}"  maxtime="10"/>
   <mobi:commandButton type="button"

Any validation that is required on this component can be done via the valueChangeListener as follows:-

  public void methodOne(ValueChangeEvent event){
        // use this method to check filetype and can possibly remove the file if not correct filetype
         if (event!=null){
            Map compMap = (HashMap)event.getNewValue();
            File fname = (File)compMap.get(CAMERA_KEY_FILE);
            //can check for valid fileType and throw FacesMessage, convert file to other type, etc.....

Component Documentation


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© Copyright 2016 ICEsoft Technologies Canada Corp.