Parse application/smil MMS MIME type on android
Asked Answered
S

3

1

So I have come across three categories of MMS message types:

Plain Text - "text/plain"

Image - "image/jpeg", "image/bmp", "image/gif", "image/jpg", "image/png"

SMIL (Synchronized Multimedia Integration Language) - "application/smil"

So I don't have an issue grabbing the data in an MMS that falls into the first two categories. However I am having trouble grabbing the data from MMS of message type application/smil

Below I have included 5 different examples of application/smil MMS messages that I have pulled from my phone.

[31, 22, -1, application/smil, 123_1.smil, 106, null, null, <0000>, 0.smil, null, null, null, <smil>
  <head>
    <layout>
      <root-layout height="160" width="240"/>
      <region fit="meet" height="67%" id="Image" left="0%" top="0%" width="100%"/>
      <region fit="meet" height="33%" id="Text" left="0%" top="67%" width="100%"/>
    </layout>
  </head>
  <body>
    <par dur="8000ms">
      <img region="Image" src="cid:992"/>
    </par>
    <par dur="8000ms">
      <img region="Image" src="cid:993"/>
    </par>
  </body>
</smil>]

.

[22, 14, -1, application/smil, null, null, null, null, <smil>, smil.xml, null, null, null, <smil>
  <head>
    <layout>
      <root-layout width="320px" height="480px"/>
      <region id="Image" left="0" top="0" width="320px" height="320px" fit="meet"/>
      <region id="Text" left="0" top="320" width="320px" height="160px" fit="meet"/>
    </layout>
  </head>
  <body>
    <par dur="5000ms">
      <img src="8555" region="Image"/>
      <text src="text_0.txt" region="Text"/>
    </par>
  </body>
</smil>]

.

[13, 11, -1, application/smil, 123_1.smil, null, null, null, <0000>, null, null, null, null, <smil> 
  <head> 
    <layout> 
      <root-layout/>  
      <region fit="scroll" height="30%" id="Text" left="0%" top="70%" width="100%"/>  
      <region fit="meet" height="70%" id="Image" left="0%" top="0%" width="100%"/> 
    </layout> 
  </head>  
  <body> 
    <par dur="10000ms"> 
      <text region="Text" src="cid:928"/> 
    </par> 
  </body> 
</smil>]

.

[16, 13, -1, application/smil, mms.smil, null, null, null, <AAAA>, AAAA, null, null, null, <smil>
    <head>
        <layout>
            <root-layout width="240" height="160"/>
            <region id="Image" width="100%" height="67%" left="0%" top="0%" fit="meet"/>
            <region id="Text" width="100%" height="33%" left="0%" top="67%" fit="meet"/>
        </layout>
    </head>
    <body>
    <par dur="8000ms"><text src="text__01.txt" region="Text"/></par></body>
</smil>]

.

[5, 5, -1, application/smil, smil.smil, 106, null, null, <0000>, smil, null, null, null, <smil>
  <head>
    <layout>
      <root-layout height="160" width="240"/>
      <region fit="meet" height="67%" id="Image" left="0%" top="0%" width="100%"/>
      <region fit="meet" height="33%" id="Text" left="0%" top="67%" width="100%"/>
    </layout>
  </head>
  <body>
    <par dur="8000ms">
      <img region="Image" src="cid:351"/>
      <text region="Text" src="cid:352"/>
    </par>
  </body>
</smil>]

How exactly do you go about parsing this type of MMS? How do other texting apps deal with different kinds of MMS's? Any help would be greatly appreciated.

Susannsusanna answered 19/7, 2012 at 8:15 Comment(0)
S
5

So the issue was that I was creating a Cursor like this

Uri uri = Uri.parse("content://mms/part");
String[] projection = new String[] { "*" };
String selection = "_id = " + messageId;
Cursor cursor = mContentResolver.query(uri, projection, selection,null, null);

The problem is the selection arg should really be

String selection = "mid = " + messageId;

Now my cursor contains multiple entries:

  1. One entry will correspond to the SMIL file. SMIL is a file format containing xml that helps an MMS viewer to know how to display the MMS. The MIME type for this entry is application/smil if you look at the column called ct (acronym for content type)

  2. Another entry will correspond to the text file that contains any text within that MMS besides the attachment. The MIME type of this will be text/plain

  3. Lastly, you will find another entry that actually has the attachment. This attachment can have a variety of different MIME types depending on what the file is. If it happens to be a jpeg it will be image/jpeg, if png it will be image/png etc...

I want to thank @wnafee for pointing this out in this post Android: what to do with application/smil MIME type .

Susannsusanna answered 23/10, 2012 at 3:44 Comment(0)
U
2

You can start here It's android MMS viewer. Support SMIL. I use this code for my current project SMIL player for android.

Uppity answered 24/7, 2012 at 6:58 Comment(4)
How do you go about creating a SmilPlayer object? Given a string which contains the SMIL tags, how can you play the SMIL file?Susannsusanna
SmilPlayer is being used here: grepcode.com/file/repository.grepcode.com/java/ext/….Egide
How do you get a URI from the application/smil mms to initiate a smilplayer? Uri msg = intent.getData(); model = SlideshowModel.createFromMessageUri(this, msg);Susannsusanna
Hey @Den, can you provide a brief example of how you play a SMIL tree?Susannsusanna
H
0

w3 has a nice library for working with SMIL. Check it out here http://www.w3.org/TR/1999/WD-smil-boston-dom-19991115/java-binding.html

Helaina answered 23/8, 2012 at 23:36 Comment(1)
Hey @Shaun, can you provide a brief example of how you play a SMIL tree?Susannsusanna

© 2022 - 2024 — McMap. All rights reserved.