Warning Older Docs! - You are viewing documentation for a previous released version of RhoMobile Suite.

Volume Module

The Volume Module is used to set the audio output volume of the device. This is the wave output volume, not the volume of the device beeper.

Syntax

volume (Module) <META> Syntax

<META HTTP-Equiv="Volume" content="[parameter]">

Volume JavaScript Object Syntax:
By default the JavaScript Object 'volume' will exist on the current page and can be used to interact directly with the volume.
To Set volume parameters via JavaScript use the following syntax: volume.parameter = 'value'; remembering to enclose your value in quotes where appropriate.

e.g. volume.setVolume = 'value';
To set multiple EMML parameters / events on a single line use the following syntax: volume.setEMML("[Your EMML Tags]");

e.g. volume.setEMML("setVolume:value");
Volume Ruby Object Syntax:
By default the Ruby Object 'Volume' will exist on the current page and can be used to interact directly with the Volume. All Methods, Parameters and Events are the same as Javascript, however, notice 'Volume' needs to start with an uppercase letter. Another difference in Ruby is that methods do not end in '()'
To Set Volume parameters via Ruby use the following syntax: Volume.parameter = 'value' remembering to enclose your value in quotes where appropriate.

e.g. Volume.setVolume = 'value'

Parameters

Items listed in this section indicate parameters, or attributes which can be set.

Name Possible Values Description Default Value
setVolume:[Value] Volume in the format 0xnnnn Specifies a new volume setting. The low-order word contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence. If a device does not support both left and right volume control, the low-order word specifies the volume level and the high-order word is ignored Device Dependant

Multi Instance

When multiple RhoElememts applications are running the following considerations should be made: The volume settings are application specific. Switching to another application which uses the volume module will cause the device volume to change to that specified by the application with focus. Only the application with Focus will have the ability to change the volume settings.

Requirements

RhoElements Version 1.0.0 or above
Supported Devices All supported devices.
Minimum Requirements The device must have a speaker.
Persistence Persistent - Changes to this module will persist when navigating to a new page.

HTML/Javascript Examples

The following example sets the device volume to its maximum for all devices

<meta http-equiv="Volume" content="SetVolume:0xFFFF">

The following example sets the device volume to its maximum for devices with a single wave output channel.

<meta http-equiv="Volume" content="SetVolume:0x00FF">

Ruby Examples

The following function sets the volume of the system and displays a popup message for the same:

def setVolume
    volume = @params['volume']
    if volume == 0
        Volume.setVolume=0x0000
        Alert.show_popup "Volume set to mute. You should not have hear a beep"
    else
        Volume.setVolume='0xFFFF'
        Alert.show_popup "Volume set to max. You should hear a loud beep"
    end    
end

It can be called from HTML using the any of the following:

<li onclick="setMaxVolume(); ">Set maximum volume</li>
<li onclick="mute(); ">Mute device</li>

Where ‘setMaxVolume()’ and ‘mute()’ are JavaScript functions defined below:

function setMaxVolume() {
    $.get('/app/VolumeControl/setVolume', {volume: 1});
    return false;
}

function mute() {
    $.get('/app/VolumeControl/setVolume', {volume: 0});
    return false;
}

The following example sets the device volume to its maximum for devices with a single wave output channel. It can be called from HTML in a manner similar to the one described above.

def setSingleChannel
    Volume.setVolume="0x00FF"
    Alert.show_popup "Volume set to mute. You should not have hear a single channel beep"
end
Back to Top