114
魔獸
SMIL彩信無法顯示的緣故
移動MMS有2種封裝格式:application/vnd.wap.multipart.mixed和application/vnd.wap.multipart.related,前者將MMS中的各類多媒體信息混合在一起,而後者則根據SMIL格式定義以幻燈片的形式進行多媒體內容播放。絕大多數彩信應用會采用multipart.related封裝彩信。如果你使用移動提供的MM7API,那麼,在發送彩信中含有SMIL文件時候,你可能遭遇雖然發送成功,但是在很多手機上都顯示錯誤的現象。在這種情況下,多半是由於SMIL文件格式不對以及ContentID的設置問題。
對於ContentID,當MMS封裝格式為multipart.mixed時,隻需要該參數即可,如果MMS封裝格式為multipart.related,則需要設置ContentID和ContentLocation。兩者內容保持一致。設置ContentID和ContentLocation隻需要調用mm7api的setContentID和setcontentLocation方法即可
實際應用中,發現有一些問題:網上絕大多數能夠找到的代碼都會舉例如下:
mmc.setContentId("100.jpg");
mmc.setContentLocation("100.jpg");
根據試驗,這樣寫代碼是會導致在某些手機無法顯示接收到的MMS的情形。原因在這裏:
Within SMIL part the reference to the media object parts shall use either Content-ID or Content-Location mechanism [RFC2557] and the corresponding WSP part headers in media object parts contain the corresponding definitions.
In case of Content-ID, the URI:s shall be without < and > (compare to [RFC2557], <IMG
SRC="cid:950120.aaCC@XIson.com">). To resolve a CID reference, "cid:" part shall be removed from the string, and the remaining string enclosed within < > marks. After this it can be compared to the value obtained from Content-ID header.
As the CID reference is only used within a single message, there shall be no need to create globally unique values for the content-ids, and there shall be no requirement for a legal address definition for the CID.
The Content-Location reference in the SMIL part shall be represented as relative URI, e.g., <img src=”myimage.jpg”>). The corresponding definition in media object parts shall be:
Content-Location: myimage.jpg
從上麵的描述得知,SMIL文件中對媒體元素的引用可以是Content-ID或者Content-Location,在使用Content-ID的情況下,SMIL文件中的引用和Content-ID的Header信息的描述方式應該如下所示:
SMIL文件的描述:<img src=” cid:950120.aaCC@XIson.com”>
Content-ID頭信息:Content-ID: <950120.aaCC@XIson.com>
而如果使用Content-Location的話,則描述方式如下:
SMIL文件的描述:<img src=”myimage.jpg”>
Content-Location頭信息:Content-Location: myimage.jpg
根據對mmc.setContentId("100.jpg")進行抓包的結果,可以看到截取部分如下:
Content-Type:application/smil
Content-Transfer-Encoding:8bit
Content-ID:100.jpg
有什麼問題嗎?——答案在這裏:缺少尖括號<>,在相當多的手機上這一點是會被忽視的,因此彩信得以正常顯示,但是對於部分手機如NEC的某些型號,它的MMS協議棧是精確匹配的。因此會導致無法根據ContentID來定位多媒體資源的情況,從而無法播放彩信。
所以,兼容性良好的做法是:
mmc.setContentId("<100.jpg>");
mmc.setContentLocation("100.jpg");
需要說明的是,當沒有設置ContentLocation的時候,很多手機也可以正常顯示彩信,而某些手機如索愛係列可能就無法正常播放。
最後更新:2017-04-03 15:21:44