Namespaces
Variants
Actions

How to use Camera in WRT Widget

Jump to: navigation, search

This article and code snippet below explains how to use Camera using Nokia Platform Services 2.0. Please note that camera support is not available in Platform Services 1.0

Article Metadata

Code Example
Installation file: Media:Camera_test.zip

Tested with
Devices(s): Nokia N97 mini

Compatibility
Platform(s): S60

Article
Keywords: Camera, startCamera
Created: vasant21 (12 Jan 2010)
Last edited: hamishwillee (13 Dec 2012)

Overview

There are two ways of including Platform Services 2.0 support in to the widget:

  • Installing platformservices_v2_0_beta.SIS, will add the JavaScript library to a common location (c:\system\widgetlibs\platformservices.js) that can be accessed by any widget.
  • Including the JavaScript library platformservices.js directly in a widget.

We will use the second option for simplicity and ease of testing the widget. In the code below we try to launch Camera and display the full path of the images which is taken while returning to the widget after talking few pictures.


Using Camera

<html>
<head>
<!-- includeing platformservices.js file -->
<script type="text/javascript" src="platformservices.js" charset= "utf-8" />
 
<script language="javascript">
 
var so = null;
// Lets first create camera object.
try{
so = com.nokia.device.load("", "com.nokia.device.camera", "");
}catch(e){
alert("Error loading camera : " + e);
return;
};
 
 
// Callback method to process the result, called when returned from the camera application.
function onCameraAppLoaded( transId, errorCode, result ){
 
if (errorCode == 0) {
// Lets display the full path of photos taken.
alert("Pictures taken : \n " + result.join("\n") );
}
};
 
// Callback method called on error.
function onCameraError( error ){
 
alert("Camera Error : " + error.message );
};
 
 
// Lets try to launch camera application.
var tid = so.startCamera(onCameraAppLoaded, onCameraError);
 
</script>
</head>
<body></body>
</html>


Sample Widget

Media:Camera_test.zip is a sample widget, install and launch, no dependencies

How to Test

  • Launch the widget first. It will start the Camera. You can take few pictures and exit from the camera application. This will bring you back to the widget displaying a dialog with the full path of the images recently taken from the camera.
This page was last modified on 13 December 2012, at 05:52.
103 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved