Bondi logo

The Bondi Gallery Module: bondi.gallery - Version 1.0

28 May 2009

Authors


Abstract

BONDI Gallery interface.

Table of Contents


Summary of Methods

InterfaceMethod
GalleryError
GalleryManagerGalleryArray getGalleries()
Galleryunsigned integer getNumberOfMediaItems()
PendingOperation open(SuccessCallback onSuccess, ErrorCallback onError)
PendingOperation refresh(SuccessCallback onSuccess, DeviceAPIErrorCallback onError)
void close()
PendingOperation changeView(SuccessCallback onSuccess, ErrorCallback onError, Map viewOptions)
MediaItemArray getMediaItems()
MediaItem getMediaItemById(unsigned long itemId)
MediaItem

1. Introduction

The BONDI Gallery interface provides access to media galleries located on the phone. A media gallery is a collection of media files (here referred to as media items), that is image, audio and video files. The number and the location of media galleries are implementation dependent. As an example, on a Windows Mobile phone a gallery can be located in the directory "\My Documents". A gallery can also be located in different directories; for example you can have a single gallery including files from "\My Documents" directory and from the memory card. The interface allows the user to create a custom view of the gallery. This means that the interface exposes an API to filter and order the list of files according to various options. As an example a user can request all images sorted by date, or mp3 files sorted by author.

1.1. Features

This is the list of URIs used to declare this API's features, for use in bondi.requestFeature. For each URL, the list of functions provided is provided.

http://bondi.omtp.org/api/gallery.read

Access to the gallery content.

Device capabilities: io.file.read

1.2. Device capabilities

io.file.read

Read gallery files from the filesystem.

Security parameters:

  • name: Name of directory or file, in virtual filesystem, e.g. rootlocation/filename

2. Type Definitions

2.1. GalleryArray

Array of Gallery objects.

        typedef sequence<Gallery>   GalleryArray;

2.2. MediaItemArray

Array of MediaItem objects.

        typedef sequence<MediaItem> MediaItemArray;

3. Interfaces

3.1. GalleryError

Gallery specific errors.

        interface GalleryError : GenericError {

                const unsigned short GALLERY_OPEN_ERROR = 1;

                const unsigned short GALLERY_NOT_OPEN_ERROR = 2;
        };

This interface inherits from: GenericError

Constants

Gallery is already open

Gallery is not open

3.2. GalleryManager

Interface retrieval of list of media galleries of the phone.

        interface GalleryManager {

                GalleryArray getGalleries();
        };

This interface allows for the retrieval of the list of Media Galleries present on the phone. The number of galleries is hardcoded in the implementation. As an example, in a windows mobile implementation it may retrieve the gallery located in the directory "\My Documents" and another one located on the memory card. The property info of each gallery can be checked to get further details.

Code example
        var availableGalleries = bondi.gallery.getGalleries();
        for (i=0; iavailableGalleries.length; i++) {
                var galleryInfo = availableGalleries[i].info;
                // check gallery info...
        }
 

Methods

getGalleries

Retrieves all galleries managed by the manager.

Signature
GalleryArray getGalleries();

The number of galleries depends on the implementation. It can return an empty array: if it does this means that the developer or phone manufacturer doesn't give access to galleries, or that there are no galleries currently available (for example, because there is no memory card in the phone).

Return value
a vector containing all available galleries.
API features
http://bondi.omtp.org/api/gallery.read
Code example
        var availableGalleries = bondi.gallery.getGalleries();
 

3.4. MediaItem

Interface to a single media item.

        interface MediaItem {

                readonly attribute unsigned long id;

                readonly attribute long type;

                readonly attribute DOMString mimeType;

                readonly attribute DOMString fileName;

                readonly attribute Map metadata;
        };

The MediaItem interface offer access to information regarding a single media item. A media item is a media file located in the gallery, that is an image, audio or video file. All information provided are readonly.

Code example
        var myPreferredPictureId = 7;
        var myPreferredPicture = gallery.getMediaItemById(myPreferredPictureId);
        if(myPreferredPicture.type == gallery.MEDIA_ITEM_TYPE_IMAGE) {
                alert("My preferred picture was taken with camera " + myPreferredPicture.metadata.cameraModel);
        }
        else {
                alert("My preferred picture is not an image...");
        }
 

Attributes

[readonly] unsigned long id

Unique Id of the media item.

This id is a unique numeric identifiers of the item. This id is persistent while the media gallery is opened, so a refresh or changeView operation will not change his value.

Code example
        var selectedItem = mediaItem.id;
 
[readonly] long type

Type of media item.

The type of the media item is an internal representation to distinguish among audio items (MEDIA_ITEM_TYPE_AUDIO), video items (MEDIA_ITEM_TYPE_VIDEO) or image items (MEDIA_ITEM_TYPE_IMAGE).

Code example
        if (mediaItem.type == gallery.MEDIA_ITEM_TYPE_IMAGE) {
                //display the image
        }
 
[readonly] DOMString mimeType

Mimetype of the media file.

This field is the mimetype associated to the media file. It can be used to open the media item with an external application.

Code example
        var mimetype = mediaItem.mimeType;
 
[readonly] DOMString fileName

Gets the name of the file corresponding to this item.

Return the full file name (including path) of the media item.

Code example
        var fileName = mediaItem.fileName;
 
[readonly] Map metadata

Metadata associated to the media item.

Informations extracted from the media file header. The return map can be: {metaTag0:<metadata tag values>, metaTag1:<metadata tag values>, ...} where metaTag0, metaTag1, ... are the fields of file's metadata.

It is also possible to iterate over the metadata collection:

Code example
        var pictureInfo = mediaItem.metadata;
        alert("Picture taken with camera " + pictureInfo.cameraModel);
 
Code example
        var metadata = mediaitem.metadata; 
        for (var metadate in metadata) {
                alert(metadate + " of " + mediaitem.fileName + " is " + metadata[metadate]);
        }