×
Namespaces

Variants
Actions

Archived:MediaData Component for Flash Lite

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.

This document explains the use of the Flash Lite MediaData data component and API.

Article Metadata
Article
Created: jaaura (19 May 2009)
Last edited: hamishwillee (14 May 2013)

(Note, this document has also been published in pdf format inside the Nokia Developer Flash Lite Components package)

Contents

Introduction to the Contacts component

The MediaData component uses the Nokia Platform Services Media Management API to read and filter media file paths from the device.

The received data is provided in the array of n filtered items, which is broadcast using EventDispatcher for all listening objects. Example of data contents: {FileName:"DX_90934", FileNameAndPath:"C:\folder\DX_90934.jpg"}, {FileName:"DX_90935", and FileNameAndPath:"C:\folder\DX_90935.jpg"}.

Requirements

Download

MediaData component is included in the Nokia Developer Flash Lite Components package.

Installation

Installation of the MediaData component is easy. Execute the components MXP file and follow the simple instructions in Adobe Extension Manager to complete the installation process. Restart Adobe Flash CS4 after installation.

Note: Component FLA and AS files should appear in the directories [INSTALL PATH]\Flash CS4\en\Configuration\Components\Nokia Developer and [INSTALL PATH]\Flash CS4\en\Configuration\Classes\com\forumnokia. In some setup environments, the files may appear under the wrong language directories (for example, fi instead of en). In such cases, the files should be manually moved to the correct directories as specified above.

Preparations

1. Create a Flash Lite Project. Open the Component panel (Ctrl/Apple key + F7) and drag the Media component onto the stage. Assign a unique instance name for the object using the properties panel (Ctrl/Apple key + F3).

Components.png

MediaData can now be read using the ActionScript API call getMediaData(). For receiving the event and reading, see the section Adding a listener, below.

Skins and assets

The data component does not have any visual elements, except the icon MediaDataComponent.png, which is not visible at runtime.

Inspectable parameters

These component parameters can be changed via the Component Inspector panel. The same parameters can also be accessed from ActionScript. Detailed instructions for filter-related parameters and key values are described in the Parameters for retrieving media information section of the Flash Lite Developer’s Library.

MediaDataComponentValues.png


Parameter Description Value
Filtered files Enable filtering to retrieve only certain media files. None, Music, Sound, Image, Video, StreamingURL; default is None
Filtered details Defines the detailed attribute for filtering. If this parameter is used, Filtering start range (the next parameter) must also be specified. None, FileName, FileExtension, Drive, FileSize, FileDate, MimeType, FileNameAndPath, SongName, Artist, Album, Genre, TrackNumber, Composer, LinkFirstURL; default is None
Filtering start range Defines the start value for the specific items to filter. Depends on the Filtered files value above. None, or for instance .jpg if the value of Filtered files is Image.; default is None
Filtering end range Defines the end value for the filtered range. Valid only for the filtered details: FileSize and FileDate, otherwise leave as None. None, or size (in bytes) or date (in form YYYYMMDD:HHMMSS), when the value of Filtered details is FileDate or FileSize; default is None
Sorting by Defines the file detail that will be used for sorting. None, or any value from Filtered details; default is None
Sorting order Sorting order Ascending, Descending; default is Ascending

MediaData Component ActionScript API

Filtering media data

public function setFilterFileType( file_type:String ): Void;

For file type, the allowed values are “None”, “Music”, “Sound”, “Image”, “Video”, and “StreamingURL”.

Setting filtering details

public function setFilterDetail( detail:String,start_range:String, end_range:String ): Void;

Sets media file attributes for filtering.

For detail, the allowed values are “None”, “FileName”, “FileExtension”, “Drive”, “FileSize”, “FileDate”, “MimeType”, “FileNameAndPath”, “SongName”, “Artist”, “Album”, “Genre”, “TrackNumber”, “Composer”, and “LinkFirstURL”.

start_range is always required. For example a file extension pattern (“.jpg”). end_range is required only if the value of detail is “FileDate” or “FileSize”. It can be a numeric value (bytes), or a date (YYYYMMDD:HHMMSS).

Setting the sorting keys

public function setSortingType( sorting_detail:String ): Void;

Defines the file detail that will be used for sorting. Allowed values are: “None”, “FileName”, “FileExtension”, “Drive”, “FileSize”, “FileDate”, “MimeType”, “FileNameAndPath”, “SongName”, “Artist”, “Album”, “Genre”, “TrackNumber”, “Composer”, “LinkFirstURL”.

Setting the sorting order

public function setSortingOrder( sorting_order:String ): Void;

Sets the sorting order. Allowed values are: “Ascending”, “Descending”.

Name of dispatched data event

public function onReceivedDataEvent(): String;

Returns the event name which the component dispatches after receiving data. By default: "onMediaDataLoadEvent".

Read media files

public function getMediaData(): Void;

Starts reading the media file information using the S60 Platform Service API (asynchronous) and broadcasts an event when the data is read.

Adding an event listener

public function addEventListener(event:String, listenerFunction:Object): Void;

The MediaData component dispatches an event when it has finished reading data. Delegate needs to be called to specify the scope of the listening function (see Advanced usage, below, for more info).

Simple use:

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, oobas, oracle11, oracle8, oxygene, oz, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, uscript, vala, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


var event_name:String = myMedia.onReceivedDataEvent();
myMedia.addEventListener( event_name, myEventHandler );

function myEventHandler( evt ){
    myData = evt.MediaData;
    //handle mediaData here (refer to Nokia Developer documentation)
}
// Read the media filenames (myEventHandler gets invoked)
myMedia.getMediaData();

Advanced use:

This example uses Delegate to make sure that the correct event is received here. It also checks the error code and parses received data.

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, oobas, oracle11, oracle8, oxygene, oz, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, uscript, vala, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


var event_name:String = myMedia.onReceivedDataEvent();
myMedia.addEventListener( event_name, Delegate.create( this, myEventHandler) );
var receivedItems:Array = [];

function myEventHandler( eventObj:Object ):Void {
    switch( eventObj.type ){
        case event_name:
            // Add your functionality here
		// First check for error
		if( myMedia.lastError() == 0 ){
                for (i = 0; i < eventObj.MediaData.length; i++){
                    receivedItems.push( eventObj.MediaData[i].FileName );
                }
                // Copy received data into List UI component
                list_mc.populateData( receivedItems );
		}
            else
            {
                // Handle the error here
            }
            break;  

        default :
            break;
    }
}

// Read the media filenames (myEventHandler gets invoked)
myMedia.getMediaData();

Removing the event listener

public function removeEventListener(event:String, listenerFunction:Object): Void;

Tells the component to stop dispatching events.

This page was last modified on 14 May 2013, at 02:40.
41 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×