×
Namespaces

Variants
Actions

How to create a SMIL message

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Code ExampleArticle
Created: visrini (18 Oct 2007)
Last edited: hamishwillee (14 Jun 2013)

SMIL stands for Synchronized Multimedia Integration Language.SMIL allows integrating a set of independent multimedia objects into a synchronized multimedia presentation. Using SMIL, an author can

  1. describe the temporal behavior of the presentation
  2. describe the layout of the presentation on a screen
  3. associate hyperlinks with media objects

SAMPLE CODE

The code snippet to create a SMIL presentation when creating a MMS message is below:

TBool CMMSExampleContainer::CreateNewMessageL()
{
CMsvEntry* entry = CMsvEntry::NewL(*iSession, KMsvGlobalOutBoxIndexEntryId,
TMsvSelectionOrdering());
CleanupStack::PushL(entry);
 
// Set context to the parent folder (Outbox)
iMmsMtm->SwitchCurrentEntryL( entry->EntryId() );
 
// Create new message in the Outbox and set it as the current context.
#ifdef __SERIES60_3X__ //3rd edition onwards
iMmsMtm->CreateMessageL( iMmsMtm->DefaultServiceL() );
#else//1st and 2nd edition
iMmsMtm->CreateMessageL( iMmsMtm->DefaultSettingsL() );
#endif
CleanupStack::PopAndDestroy(); // entry
 
// Setting recipients
// use this to add the "To" recipients.
iMmsMtm->AddAddresseeL( _L("9841840648") );
 
//Setting message subject
_LIT(KMessageSubject, "MMS Example");
iMmsMtm->SetSubjectL(KMessageSubject);
 
// Message consists of one image
#ifndef __HARDCODED_PATHS__ //3rd and 2nd edition
TFileName attachmentFile(KPhoneRootPath);
attachmentFile.Append(KDirPictures);
TFileName fileName(KFileName);
attachmentFile.Append(KFileName);
#else//1st edition
TFileName attachmentFile(KDirPictures);
attachmentFile.Append(KFileName);
#endif
 
TMsvEntry ent = iMmsMtm->Entry().Entry();
// Set InPreparation to false
ent.SetInPreparation(EFalse);
ent.SetVisible(ETrue);
iMmsMtm->Entry().ChangeL(ent); // Commit changes
 
#ifdef __SERIES60_3X__ //adding attachment 3rd edition onwards
//Save the changes
iMmsMtm->SaveMessageL();
 
//Opening store
CMsvStore* store = iMmsMtm->Entry().EditStoreL();
CleanupStack::PushL(store);
 
RFile attachment;
//open attachment file
TInt error = attachment.Open( CCoeEnv::Static()->FsSession(), attachmentFile,
EFileShareReadersOnly | EFileRead );
CleanupClosePushL( attachment );
 
//Check that the attachment file exist.
if(error != KErrNone)
{
attachment.Close();
CleanupStack::PopAndDestroy(); // attachment
CleanupStack::PopAndDestroy(); // store
return EFalse;
}
else
{
// GIF IMAGE
//mime header
CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
CleanupStack::PushL( mimeHeaders );
mimeHeaders->SetSuggestedFilenameL(fileName);
mimeHeaders->SetContentLocationL( fileName );
// Represents a single attachment and information about the attachment
CMsvAttachment* attaInfo = CMsvAttachment::NewL( CMsvAttachment::EMsvFile );
CleanupStack::PushL( attaInfo );
//Mime Type
_LIT8(KMimeType, "image/gif");
TBufC8<20> mimeType(KMimeType);
TMsvAttachmentId attachId = KMsvNullIndexEntryId;
//Attachment file must be an public folder (e.g. c:\Data\images)
iMmsMtm->CreateAttachment2L(
*store,
attachment,
mimeType,
*mimeHeaders,
attaInfo,
attachId );
CleanupStack::Pop( attaInfo ); // attaInfo
CleanupStack::PopAndDestroy(mimeHeaders); // mimeHeaders
attachment.Close();
CleanupStack::PopAndDestroy(); // attachment
 
// PLAIN TEXT
#ifndef __HARDCODED_PATHS__ //3rd and 2nd edition
attachmentFile.Copy(KPhoneRootPath);
attachmentFile.Append(KDirPictures);
TFileName fileName2(KFileName2);
attachmentFile.Append(KFileName2);
#else//1st edition
TFileName attachmentFile(KDirPictures);
attachmentFile.Append(KFileName2);
#endif
TInt err = attachment.Open( CCoeEnv::Static()->FsSession(), attachmentFile,
EFileShareReadersOnly | EFileRead );
CleanupClosePushL( attachment );
//mime header
mimeHeaders = CMsvMimeHeaders::NewL();
CleanupStack::PushL( mimeHeaders );
mimeHeaders->SetSuggestedFilenameL(fileName2);
mimeHeaders->SetContentLocationL( fileName2 );
// Represents a single attachment and information about the attachment
attaInfo = CMsvAttachment::NewL( CMsvAttachment::EMsvFile );
CleanupStack::PushL( attaInfo );
//Mime Type
_LIT8(KMimeTypeText, "text/plain");
TBufC8<20> mimeType2(KMimeTypeText);
attachId = KMsvNullIndexEntryId;
//Attachment file must be an public folder (e.g. c:\Data\images)
iMmsMtm->CreateAttachment2L(
*store,
attachment,
mimeType2,
*mimeHeaders,
attaInfo,
attachId );
 
CleanupStack::Pop( attaInfo ); // attaInfo
CleanupStack::PopAndDestroy(mimeHeaders); // mimeHeaders
attachment.Close();
CleanupStack::PopAndDestroy(); // attachment
 
// GIF IMAGE
#ifndef __HARDCODED_PATHS__ //3rd and 2nd edition
attachmentFile.Copy(KPhoneRootPath);
attachmentFile.Append(KDirPictures);
TFileName fileName4(KFileName4);
attachmentFile.Append(KFileName4);
#else//1st edition
TFileName attachmentFile(KDirPictures);
attachmentFile.Append(KFileName2);
#endif
err = attachment.Open( CCoeEnv::Static()->FsSession(), attachmentFile,
EFileShareReadersOnly | EFileRead );
CleanupClosePushL( attachment );
//mime header
mimeHeaders = CMsvMimeHeaders::NewL();
CleanupStack::PushL( mimeHeaders );
mimeHeaders->SetSuggestedFilenameL(fileName4);
mimeHeaders->SetContentLocationL( fileName4 );
// Represents a single attachment and information about the attachment
attaInfo = CMsvAttachment::NewL( CMsvAttachment::EMsvFile );
CleanupStack::PushL( attaInfo );
attachId = KMsvNullIndexEntryId;
//Attachment file must be an public folder (e.g. c:\Data\images)
iMmsMtm->CreateAttachment2L(
*store,
attachment,
mimeType,
*mimeHeaders,
attaInfo,
attachId );
CleanupStack::Pop( attaInfo ); // attaInfo
CleanupStack::PopAndDestroy(mimeHeaders); // mimeHeaders
attachment.Close();
CleanupStack::PopAndDestroy(); // attachment
 
// SMIL FILE
#ifndef __HARDCODED_PATHS__ //3rd and 2nd edition
attachmentFile.Copy(KPhoneRootPath);
attachmentFile.Append(KDirPictures);
TFileName fileName3(KFileName3);
attachmentFile.Append(KFileName3);
#else//1st edition
TFileName attachmentFile(KDirPictures);
attachmentFile.Append(KFileName3);
#endif
attachment.Open( CCoeEnv::Static()->FsSession(), attachmentFile,
EFileShareReadersOnly | EFileRead );
CleanupClosePushL( attachment );
//mime header
mimeHeaders = CMsvMimeHeaders::NewL();
CleanupStack::PushL( mimeHeaders );
mimeHeaders->SetSuggestedFilenameL(fileName3);
// Represents a single attachment and information about the attachment
attaInfo =CMsvAttachment::NewL( CMsvAttachment::EMsvFile );
CleanupStack::PushL( attaInfo );
//Mime Type
_LIT8(KMimeTypeSMIL, "application/smil");
TBufC8<20> mimeType3(KMimeTypeSMIL);
attachId = KMsvNullIndexEntryId;
//Attachment file must be an public folder (e.g. c:\Data\images)
iMmsMtm->CreateAttachment2L(
*store,
attachment,
mimeType3,
*mimeHeaders,
attaInfo,
attachId );
CleanupStack::Pop( attaInfo ); // attaInfo
CleanupStack::PopAndDestroy(mimeHeaders); // mimeHeaders
iMmsMtm->SetMessageRootL(attachId);
attachment.Close();
CleanupStack::PopAndDestroy(); // attachment
store->CommitL();
CleanupStack::PopAndDestroy(); // store
// message must be saved to save the root id
iMmsMtm->SaveMessageL();
}
 
#else //1st and 2nd edition
//Check that the attachment file exists.
if(!ConeUtils::FileExists(attachmentFile))
{
return EFalse;
}
else
{
TBufC8<20> content;
//slide 1
//TEXT
attachmentFile = KDirPictures ;
attachmentFile.Append(KFileName2);
TMsvId attachmentID = KMsvNullIndexEntryId;
iMmsMtm->CreateAttachment2L( attachmentID, attachmentFile );
iMmsMtm->SetAttachmentNameL(attachmentID, _L("Smil.txt"));
content = _L8( "text/plain" );
iMmsMtm->SetAttachmentTypeL( attachmentID, content );
 
//GIF
attachmentFile = KDirPictures;
attachmentFile.Append(KFileName);
attachmentID = KMsvNullIndexEntryId;
iMmsMtm->CreateAttachment2L( attachmentID, attachmentFile );
iMmsMtm->SetAttachmentNameL(attachmentID, _L("flower.gif"));
content = _L8( "image/gif" );
iMmsMtm->SetAttachmentTypeL( attachmentID, content );
 
//slide 2
attachmentFile = KDirPictures;
attachmentFile.Append(KFileName4);
attachmentID = KMsvNullIndexEntryId;
iMmsMtm->CreateAttachment2L( attachmentID, attachmentFile );
iMmsMtm->SetAttachmentNameL(attachmentID, _L("animation1.gif"));
content = _L8( "image/gif" );
iMmsMtm->SetAttachmentTypeL( attachmentID, content );
 
//SMIL
attachmentFile = KDirPictures;
attachmentFile.Append(KFileName3);
attachmentID = KMsvNullIndexEntryId;
iMmsMtm->CreateAttachment2L( attachmentID, attachmentFile );
iMmsMtm->SetAttachmentNameL(attachmentID, _L("tc003.smil"));
content = _L8( "application/smil" );
iMmsMtm->SetAttachmentTypeL( attachmentID, content );
iMmsMtm->SetMessageRootL(attachmentID);
 
}
iMmsMtm->SaveMessageL();
#endif
 
return ETrue;
}

Example Project

File:MMSExample.zip

Internal Links

SMIL

This page was last modified on 14 June 2013, at 06:31.
33 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.

×