【问题标题】:Parse application/smil MMS MIME type on android在 android 上解析 application/smil MMS MIME 类型
【发布时间】:2012-07-18 09:20:36
【问题描述】:

所以我遇到了三类彩信类型:

Plain Text - "text/plain"

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

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

因此,我在 MMS 中获取属于前两类的数据时没有问题。但是我无法从消息类型为application/smil 的彩信中获取数据

下面我列出了我从手机中提取的 5 个不同的application/smil MMS 消息示例。

[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>]

您究竟是如何解析这种类型的彩信的?其他短信应用程序如何处理不同类型的彩信?任何帮助将不胜感激。

【问题讨论】:

    标签: android sms mime-types mms


    【解决方案1】:

    所以问题是我正在创建一个像这样的Cursor

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

    问题是选择 arg 真的应该是

    String selection = "mid = " + messageId;
    

    现在我的光标包含多个条目:

    1. 一个条目将对应于 SMIL 文件。 SMIL 是一种包含 xml 的文件格式,可帮助 MMS 查看器了解如何显示 MMS。如果您查看名为 ct(内容类型的首字母缩写词)的列,则此条目的 MIME 类型是 application/smil

    2. 另一个条目将对应于包含该 MMS 中除附件之外的任何文本的文本文件。它的 MIME 类型将是 text/plain

    3. 最后,您会发现另一个条目实际上包含附件。此附件可以有多种不同的 MIME 类型,具体取决于文件的内容。如果它碰巧是 jpeg,它将是 image/jpeg,如果是 png,它将是 image/png 等等......

    我要感谢 @wnafee 在这篇帖子 Android: what to do with application/smil MIME type 中指出这一点。

    【讨论】:

      【解决方案2】:

      你可以开始here 它是安卓彩信查看器。支持 SMIL。 我将此代码用于我当前的项目 SMIL player for android。

      【讨论】:

      • 如何创建 SmilPlayer 对象?给定一个包含 SMIL 标签的字符串,如何播放 SMIL 文件?
      • 如何从 application/smil mms 获取 URI 来启动 smilplayer? Uri msg = intent.getData(); model = SlideshowModel.createFromMessageUri(this, msg);
      • 嘿@Den,你能提供一个简单的例子来说明你如何玩 SMIL 树吗?
      【解决方案3】:

      w3 有一个很好的库来处理 SMIL。在这里查看http://www.w3.org/TR/1999/WD-smil-boston-dom-19991115/java-binding.html

      【讨论】:

      • 嘿@Shaun,你能提供一个简单的例子来说明你是如何玩 SMIL 树的吗?
      猜你喜欢
      • 2014-08-12
      • 2014-08-12
      • 2013-05-31
      • 2013-08-13
      • 1970-01-01
      • 2010-12-21
      • 1970-01-01
      • 1970-01-01
      • 2011-06-24
      相关资源
      最近更新 更多