BYU Home pageBRIGHAM YOUNG UNIVERSITY
  Office of Digital Humanities
Back     BYU LiveCode Lessons Gateway

Mobile Photos Album and Camera Control

LiveCode provides several language features for choosing photos from the device's built-in photo library, and for taking a still photograph with the device's built-in camera. Details can be found by searching in the LiveCode Dictionary for each of the following commands. Following is a summary of the commands and functions you can use to control the camera and access the photo album.

mobilePickPhoto command

This command allows the user to select an image to display using a native photo picker.

Syntax:

mobilePickPhoto source, maxwidth, maxheight

Where source is one of the following:

Note that the maxwidth and maxheight parameters are only available in iOS. They specify the maximum allowable width and height of the chosen image.

Example:

put the width of this stack div 2 into tMaxWidth
put the height of this stack div 2 into tMaxHeight
mobilePickPhoto "library", tMaxWidth, tMaxHeight

The stack "testMobileControls.livecode" that we examined in class shows a simple example of the use of this command as well as the other functions and commands on this page.

mobileCameraFeatures function

This function queries the features of the specified camera and returns the results as a comma-delimited list.

Syntax:

mobileCameraFeatures(camera)

Where camera is one of the following:

Example:

put mobileCameraFeatures("front") into tFeatureList

For instance, in a test on an iPad 3rd Generation, this statement:

put mobileCameraFeatures() into fld "display"

Produced the following list:

front photo,front video,rear photo,rearvideo

mobileExportImageToAlbum command

This command saves an image to the user's photo album (iOS) or default pictures folder (Android).

Syntax:

mobileExportImageToAlbum imageData or longImageID, fileName

Where imageData is the binary data of an image object (e.g., the text of image "foo")

- or -

longImageID is a long id reference to an image object.

Example:

put the long id of last image into tImgID
mobileExportImageToAlbum tImgID

The fileName parameter is optional, and is the name under which the image is to be saved on the Android file system.

The mobileExportImageToAlbum command returns empty in the result if exporting succeeded. Otherwise it returns one of:


Back     BYU LiveCode Lessons Gateway
Maintained by Devin Asay.
Copyright © 2005 Brigham Young University