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 01:17, 4 July 2008.

How to create a SMIL message

From Forum Nokia Wiki

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

http://wiki.forum.nokia.com/index.php/Image:MMSExample.zip

Internal Links

http://wiki.forum.nokia.com/index.php/SMIL

Related Discussions
Thread Thread Starter Forum Replies Last Post
MMS w/SMIL to Nokia devices Tom.Aellen General Messaging 3 2003-06-09 14:29
MMS Java Library problem lichuanqi Web Technologies and Multimedia Content- Web 技术和多媒体内容 1 2003-05-29 09:15
MMS and HTML content (CT_TEXT_HTML) mferisak General Messaging 0 2003-10-29 10:17
SMIL Animations andersgortz General Messaging 1 2004-12-10 08:26
problems parsing smil file pburrows2 General Messaging 2 2004-01-06 11:44
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZmmsQ
     qfnZtopicQUqfnTopicZsmilQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX