SolutionsTools & SDKSupport  



Quick Links
 
January 2004
 
 
Jack's Hack for the month of January, 2004:

Using the Openwave MMS SDK to Construct and Deliver SMIL

This month in Jack's Hacks, we'll take a look at another new feature In the 2.1 Release of the Openwave MMS SDK. In addition to the ability to query device information, we have introduced an API which allows developers to dynamically create slide show presentations without having to use pre-existing SMIL content. This API provides a the ability to build more compelling messaging applications and deliver a rich end user experience without having to manage SMIL markup independently. The API to deliver content as attachments without the SMIL, or deliver pre-existing SMIL still persists, but this new functionality helps developers take the next step. Read the full article

The Multimedia Content API can be used in conjunction with the submit and deliver messages to allow users to compose and decompose SMIL-based multimedia content. With this API, a user can make presentations or slide shows with SMIL content. The API also allows clients to import SMIL-based content developed using a third-party tool. The SMIL generated and understood by this API conforms to the MMS Conformance Document available from the Open Mobile Alliance website as part of the OMA Multimedia Messaging Service version 1.1 specifications.

The API consists of objects corresponding to the different multimedia objects that can be sent in a multimedia message, such as Image, Text and Audio. A Slide object is used to represent one slide in a multimedia presentation. A Slide contains one or more multimedia objects. The MultimediaContent object encapsulates the entire multimedia presentation consisting of many slides. Each presentation can also have a template which specifies the coordinates of regions on the screen where the different multimedia objects like Image and Text are displayed. A Template object encapsulates this concept.

The MultimediaContent, Slide and Template classes are defined as Java interfaces. Each of these interfaces have a default implementation class associated with them. In order to hide the implementation details from the users of the API, the Factory pattern is used to provide access to the default implementations. Each of these interfaces has a factory class associated with them which creates instances of these objects? implementations. There is also a Factory class which acts as a Facade to all the different factory classes for convenience.

The MultimediaContent constructor can construct a MultimediaContent object from the JavaMail MimeMultipart object provided, or by reading the given file. When parsing a JavaMail MimeMultipart object, it looks for the MIME part that contains the SMIL description of the content and constructs the slides accordingly. The file supplied could be a directory, a SMIL file or a zip file. If it is a directory, the method lists the files in the directory, picks the first file with an extension .smil, and constructs the MultimediaContent object from it. If it is a SMIL file, the method constructs the MultimediaContent object as described by the SMIL file. If it is a zip file, the method treats it as a directory and constructs the MultimediaContent object accordingly.

To compose SMIL-based multimedia content, follow these steps:

  1. Create the MultimediaContent object using the Factory.newMultimediaContent method.
  2. Create a Template object using the TemplateFactory.newTemplate method. This step is optional. The API uses the DefaultTemplate when a template is not specified.
  3. Use the MultimediaContent.newSlide or Factory.newSlide method to create a new Slide and add media objects to it using the methods in Slide. When using the Factory.newSlide method to create a new Slide object, the object needs to be added to the MultimediaContent object using the addSlide method.
  4. Pass the MultimediaContent object to the SubmitRequest.setContent method.
Got that? Good. Here's a look at a code snippet that actually empolys the procedures described above. The good news is that it's arlready implemented for you in the MM7MessageSender.java file that is part of the MMS SDK 2.1. Here is a quick peek at the relevant code where we are creating a slide from files:
...
        Slide slide = Factory.getInstance().newSlide();

        if( textFile != null ) {
            slide.setText( new Text( new File( textFile ), null ) );
        }
        if( imageFile != null ) {
            slide.setImage( new Image( new File( imageFile ) ) );
        }
        if( audioFile != null ) {
            slide.setAudio( new Audio( new File( audioFile ) ) );
        }
        if( duration > 0 ) {
            slide.setDuration( duration );
        }
...

Once the slide (or slides) are built, sending them is pretty straight forward:

...
SubmitRequest request = createSubmitRequest( slides, mmFiles, userName,  recipients );
        Response response = null;
        try {
            response = conn.sendRequest( request );
            SubmitResponse submitResponse = ( SubmitResponse ) response;
            printResponse( submitResponse );
        } catch( ClassCastException cce ) {
...

So, we've taken a very quick look at the MultiMedia APIs that are part of the Openwave MMS SDk 2.1. If you've not done so already, besure to take a look at the MMS Quickstart Guide , and Chapter 10 of the MMS Developer Guide. See you next time!



 
Copyright © 2000-2008 Openwave Systems Inc.    Openwave  |  Terms & Conditions  |  Privacy Policy