Namespaces
Variants
Actions
(Difference between revisions)

Archived:Media File Symbian API

Jump to: navigation, search
m (Automated change of text from {{NoteS}} to {{Note|. (using newer note template))
m (Hamishwillee - Bot change of template (Template:CodeSnippet) - now using Template:ArticleMetaData)
Line 3: Line 3:
 
__NOEDITSECTION__
 
__NOEDITSECTION__
 
{{KBCS}}
 
{{KBCS}}
{{CodeSnippet
+
{{ArticleMetaData
 
|id=CS001036
 
|id=CS001036
 
|platform=S60 3rd Edition, FP2
 
|platform=S60 3rd Edition, FP2
Line 11: Line 11:
 
|creationdate=June 13, 2008
 
|creationdate=June 13, 2008
 
|keywords=Media File API
 
|keywords=Media File API
 +
 +
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 +
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. -->)
 +
|author=[[User:Technical writer 1]]
 
}}
 
}}
  

Revision as of 11:31, 24 June 2011

Template:KBCS

Article Metadata

Compatibility
Platform(s): S60 3rd Edition, FP2

Platform Security
Capabilities: )

Article
Keywords: Media File API
Created: User:Technical writer 1 (13 Jun 2008)
Last edited: hamishwillee (24 Jun 2011)


Note.png
Note: :This API is not part of the public SDK. It can be found in the SDK API Plug-in.

The Media File API is responsible for sending notifications about file updates to the Media Gallery. It also offers an API to check duplicate media files, that is, to check if the file name is a unique media file name in the phone memory or the multimedia card.

Header files

 #include <MGXFileManagerFactory.h>
 #include <CMGXFileManager.h>
 #include <CMGXFileNotificationHandler.h>
 #include <MMGXFileNotificationObserver.h>

Link against

 LIBRARY   MGXMediafileapi.lib

Required capability

 CAPABILITY  ReadUserData WriteDeviceData

Example code

Creating File Manager and the file notification handler

 CMGXFileManager* iFileManager = MGXFileManagerFactory::NewFileManagerL(
iCoeEnv->FsSession() );
CMGXFileNotificationHandler* iFNH =
MGXFileManagerFactory::NewFileNotificationHandlerL();

Updating a file

There are different file update types:
1) A general update to the media gallery.
2) Notify Media Gallery after saving a file from a viewer application.
3) Notify Media Gallery after renaming a media file.
4) Update Media Gallery files (an array of files).

The code snippet to send an update is:

 // Create an array of descriptors for the selected files
CDesCArrayFlat* fileArray = new (ELeave) CDesCArrayFlat(5);
CleanupStack::PushL(fileArray);
TBool allowMultiple(EFalse);
TBuf <20> lHeading;
lHeading.Append(_L("Image Files"));
// Open the dialog. this is overloaded
TBool ret = MGFetch::RunL(*fileArray,EImageFile,allowMultiple,KNullDesC,lHeading);
if( ret )
{
BaflUtils::RenameFile(CEikonEnv::Static()->FsSession(),
fileArray->MdcaPoint(0),_L("c:\\Data\\Images\\new.bmp"));
iContainer->SetTextL( _L("File Renamed") );
iFileManager->UpdateL(fileArray->MdcaPoint(0),_L("c:\\Data\\Images\\new.bmp"));
}
else
{
iContainer->SetTextL( _L("File Not Selected") );
}
CleanupStack::PopAndDestroy(); // fileArray

Checking for duplicate file names :

 TBool ret = iFileManager->SuccessFileNameL( iFileName, EDriveC );
//To check for file in phone memory.
//iFileName is filename to be checked.
//To check if it exists in MMC use "EDriveE" instead of "EDriveC"

Register and unregister observer

You can also register to get notifications of changed media files (for example, new files are created or existing files are modified or deleted, etc.)

1) Derive your class from MMGXFileNotificationObserver and implement the pure virtual function HandleFileNotificationEventL.
2) Register for observations:

 iFNH->SetObserver( *this )

3) Unregister to stop getting notifications :

 iFNH->RemoveObserver(*this);

Example project

File:MediaFileEx.zip

480 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