Package com.objectxp.mms.message.smil

The smil package contains classes for constructing SMIL (Synchronized Multimedia Integration Language) documents.

See: Description

Package com.objectxp.mms.message.smil Description

The smil package contains classes for constructing SMIL (Synchronized Multimedia Integration Language) documents.

SMIL is a simple XML-based language that consists of a set of modules that define the semantics and syntax for certain areas of functionality. Examples of these modules are layout module, timing module and animation module. For more Information about SMIL visit http://www.w3.org/TR/smil20/.

SMIL provides extended capabilities to display messages on the target device, such as timing of multimedia objects.

Below is an example of a SMIL document which times two multimedia objects:

  1. Display the content of the object 'hello.txt' for 5 seconds
  2. Display the the image 'picture.jpg' for another 5 seconds
    <smil>
      <head>
        <layout><root-layout width="160" height="140"/></layout>
      </head>
      <body>
        <par dur="5s">
          <text src="hello.txt"/>
        </par>
        <par dur="5s">
          <img src="picture.jpg"/>
        </par>
      </body>
    </smil>
Assuming that the SMIL document above (and the two referenced objects - 'hello.txt' and 'picture.jpg') are stored in "/tmp/smil.xml", you could construct a SMILMessage like this:
    SMILMessage msg = new SMILMessage(new File("/tmp/smil.xml").toURL());

The way to create the same document using the classes in this package is shown below:

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import com.objectxp.mms.message.smil.Body;
import com.objectxp.mms.message.smil.Head;
import com.objectxp.mms.message.smil.Image;
import com.objectxp.mms.message.smil.Layout;
import com.objectxp.mms.message.smil.RootLayout;
import com.objectxp.mms.message.smil.SmilDocument;
import com.objectxp.mms.message.smil.Text;
import com.objectxp.mms.message.smil.Timer;

/**
 * This example Demonstrates how to construct a SMIL document using jSMS.
 */
public class SmilExample 
{
  public static void main(String[] argsthrows FileNotFoundException, IOException 
  {
    // create a new SMIL document
    SmilDocument doc = new SmilDocument();

    // Head and Body elements
    Head head = new Head();
    Body body = new Body();

    doc.addElement(head);
    doc.addElement(body);

    Layout layout = new Layout();
    RootLayout rl = new RootLayout();
    rl.addAttribute(RootLayout.WIDTH, "160");
    rl.addAttribute(RootLayout.HEIGHT, "140");
    layout.addElement(rl);
    head.addElement(layout);

    // add first element
    Timer part1 = new Timer();
    part1.addAttribute(Timer.TIMING_DUR, "5s");
    body.addElement(part1);
    part1.addElement(
      new Text("Hello World".getBytes()"hello.txt""text/plain"));

    // add second part
    Timer part2 = new Timer();
    part2.addAttribute(Timer.TIMING_DUR, "5s");
    body.addElement(part2);
    part2.addElement(
      new Image(
        new FileInputStream("/tmp/picture.jpg"),
        "picture.jpg",
        "image/jpeg"));
}

object XP, Inc. © 2000-2013. All rights reserved object XP