Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 06:46, 13 June 2008.

CS001036 - Media File API

From Forum Nokia Wiki


ID CS001036 Creation date June 13, 2008
Platform S60 3rd Edition, FP2 Tested on devices  
Category S60 3rd Edition, FP2 Subcategory Media


Keywords (APIs, classes, methods, functions): Media File API


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

Image:MediaFileEx.zip

Related Discussions
Thread Thread Starter Forum Replies Last Post
listRoots does not work on s60 emulator desijatt Mobile Java General 6 2007-02-02 16:25
MMAPI on 6630? grahamhughes Mobile Java Media (Graphics & Sounds) 5 2005-05-23 14:59
Media server 1xuname1x General Symbian C++ 0 2005-11-08 05:44
J2Se Obex Server to receive files alam.sher Bluetooth Technology 22 2008-07-17 13:49
java.awt zafalimited Mobile Java General 1 2006-02-22 11:55
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZmediaQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX