Archived:Media File Symbian API
debjit.roy
(Talk | contribs) (Debjit.roy -) |
m (Lpvalente -) |
||
| (6 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | [[Category:Symbian C++]][[Category:S60 3rd Edition | + | [[Category:Symbian C++]][[Category:S60 3rd Edition FP2]][[Category:Media]][[Category:Code Examples]][[Category:Code Snippet]] |
| − | + | {{Archived|timestamp=20120313122044|user=roy.debjit| }} | |
| − | + | {{ArticleMetaData <!-- v1.2 --> | |
| − | {{ | + | |sourcecode= [[Media:MediaFileEx.zip]] |
| − | {{ArticleMetaData | + | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> | |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]) --> | + | |devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') --> |
| − | |devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) --> | + | |sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> |
| − | |signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer --> | + | |platform= S60 3rd Edition, FP2 |
| − | |capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. --> | + | |devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) --> |
| − | |author=[[User:Technical writer 1]] | + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> |
| + | |signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer --> | ||
| + | |capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | ||
| + | |keywords= Media File API | ||
| + | |language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | ||
| + | |translated-by= <!-- [[User:XXXX]] --> | ||
| + | |translated-from-title= <!-- Title only --> | ||
| + | |translated-from-id= <!-- Id of translated revision --> | ||
| + | |review-by= <!-- After re-review: [[User:username]] --> | ||
| + | |review-timestamp= <!-- After re-review: YYYYMMDD --> | ||
| + | |update-by= <!-- After significant update: [[User:username]]--> | ||
| + | |update-timestamp= <!-- After significant update: YYYYMMDD --> | ||
| + | |creationdate= 20080612 | ||
| + | |author= [[User:Technical writer 1]] | ||
| + | <!-- The following are not in current metadata --> | ||
| + | |subcategory= Media | ||
| + | |id= CS001036 | ||
}} | }} | ||
| Line 25: | Line 31: | ||
:This API is not part of the public SDK. It can be found in the [[SDK API Plug-in]]. | :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 | + | {{Abstract|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== | ==Header files== | ||
| Line 39: | Line 44: | ||
<code cpp> | <code cpp> | ||
| − | LIBRARY | + | LIBRARY MGXMediafileapi.lib |
</code> | </code> | ||
==Required capability== | ==Required capability== | ||
<code cpp> | <code cpp> | ||
| − | CAPABILITY | + | CAPABILITY ReadUserData WriteDeviceData |
</code> | </code> | ||
| Line 94: | Line 99: | ||
//To check for file in phone memory. | //To check for file in phone memory. | ||
//iFileName is filename to be checked. | //iFileName is filename to be checked. | ||
| − | //To check if it exists in MMC | + | //To check if it exists in MMC use "EDriveE" instead of "EDriveC" |
</code> | </code> | ||
| Line 101: | Line 106: | ||
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.) | 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 | + | 1) Derive your class from MMGXFileNotificationObserver and implement the pure virtual function {{Icode|HandleFileNotificationEventL}}.<br> |
2) Register for observations: | 2) Register for observations: | ||
<code cpp> | <code cpp> | ||
| Line 112: | Line 117: | ||
==Example project== | ==Example project== | ||
| − | [[ | + | [[File:MediaFileEx.zip]] |
Latest revision as of 16:05, 23 January 2013
Article Metadata
Code Example
Compatibility
Article
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.
Contents |
Header files
#include <MGXFileManagerFactory.h> #include <CMGXFileManager.h> #include <CMGXFileNotificationHandler.h> #include <MMGXFileNotificationObserver.h>
Link against
LIBRARY MGXMediafileapi.libRequired 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);

