Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 05:45, 4 October 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Controlling vibration in Symbian Web Runtime

From Wiki
Jump to: navigation, search
Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic
Platform(s): S60 3rd Edition FP2 and later
S60 5th Edition
Keywords: x-systeminfo-widget, SystemInfo.startvibra(), SystemInfo.stopvibra()
Created: dekuykin (26 Feb 2009)
Last edited: hamishwillee (04 Oct 2012)



This code snippet demonstrates how to use the device's vibration function by using the SystemInfo Service API of the Web Runtime version 1.0.

The API is supported from S60 3rd Edition FP2 onwards. It is also supported in select S60 3rd Edition, Feature Pack 1 devices or their newest firmware versions (for example, Nokia E90 Communicator, from v.210.34.75 onwards).

Source file: Relevant HTML components

<embed type="application/x-systeminfo-widget" hidden="yes" />
<input id="startVibraButton" type="button" value="Start vibra"
onclick="startVibra();" />
<input id="stopVibraButton" type="button" value="Stop vibra"
onclick="stopVibra();" />
<p>Vibra intensity</p>
<input type="radio" name="intensity" id="min" value="min" />
<label for="min">Minimal</label>
<input type="radio" name="intensity" id="mid" value="min" />
<label for="mid">Middle</label>
<input type="radio" name="intensity" id="max" value="min" />
<label for="max">Maximal</label>


// Global variable for System Info object
var sysinfo = null;
window.onload = init;
// Initializes the widget
function init() {
// Get access to SystemInfo API
// ...
// Set default vibra intensity to minimum value
document.getElementById('min').checked = true;
* Obtain reference to SystemInfo API from embedded object.

function initSysInfo() {
try {
// Get access to SystemInfo API
sysinfo = document.embeds[0];
} catch (e) {
alert('Setup error: ' + e);
function startVibra() {
// Set vibra intensity to minimum value
var vibraIntensity = sysinfo.vibraminintensity;
try {
if (document.getElementById('mid').checked) {
// Set vibra intensity to middle value
vibraIntensity = Math.ceil((sysinfo.vibraminintensity +
sysinfo.vibramaxintensity) / 2);
} catch (e) {
alert("Error: " + e);
try {
if (document.getElementById('max').checked) {
// Set vibra intensity to maximum value
vibraIntensity = sysinfo.vibramaxintensity;
} catch (e) {
alert("Error: " + e);
// Start vibra
sysinfo.startvibra(sysinfo.vibramaxduration, vibraIntensity);
alert("Vibration started!");
function stopVibra() {
// Stop vibra
alert("Vibration stopped!");


Different possibilities for controlling the vibration are demonstrated.

Supplementary material

This code snippet is part of the stub concept, which means that it has been patched on top of a template application in order to be more useful to developers. The version of the WRT stub application used as a template in this snippet is v1.1.

This page was last modified on 4 October 2012, at 05:45.
58 page views in the last 30 days.