CrossBrowdy - Basic tutorial

Device

Vibration

It is possible to make a device vibrate (through the Vibration API or compatible ones as Apache Cordova's Vibration plugin). Here is an example of device vibration management:


	//Device vibration management:
	if (CB_Device.Vibration.isSupported())
	{
		CB_console("The device vibration is supported (through the Vibration API or compatible ones as Apache Cordova's Vibration plugin).");
		 
		//Starts vibrating:
		CB_Device.Vibration.start([2000, 1000, 3000, 1000, 5000]); //Vibrates 2 seconds, waits 1 second, vibrates 3 seconds, waits 1 second and vibrates 5 seconds.
		
		//Stops vibrating (this should normally be done after some time unless we want to stop the previous vibration immediately):
		CB_Device.Vibration.stop(); //The same as calling 'CB_Device.Vibration.start(0)'.
	}
	else
	{
		CB_console("The device vibration is not supported.");
	}

Check the API documentation to read more about the CB_Device and the CB_Device.Vibration static classes.

Go back to Guides & Tutorials

« PrevReturnNext »
CrossBrowdy by Joan Alba Maldonado