In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to add attachment setattachment to MMS. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The specific implementation form of MMS in Android Mms applications, or the data structure is SlideshowModel, it is an ArrayList,SlideModel with each node of SlideModel is a List of Model, that is, it can receive subclasses of any Model, Audio,Video,Image and Text can be put on top of SlideModel. SlideModel is mainly used to manage the media above it, such as their layout, their playback control, while SlideshowModel is mainly used to manage all attachments, such as converting all attachments to Pdu of Android's MMS protocol, and from Pdu to SlideshowModel.
Pdu is a standard format that implements the MMS protocol, it can be sent directly to MMSC, and the data retrieved from MMSC is also a Pdu format. The application layer Mms does not need to care about the specific implementation of Pdu. There is an internal package in Android, com.google.android.mms.*. All the classes under the package are designed to deal with MMS on the Android platform. It provides work to package application layer data, such as media files, into Pdu, and then decompose Pdu into media files. The data structure of Pdu includes PduBody, which is the place where multimedia files are stored, in which is a collection of PduPart, and each PduPart represents a file. PduPersister is used to manipulate these data structures, including writing to and reading from the database.
SlideshowModel or commonly known as slides is the implementation of the application layer MMS, or it is a data structure used by the application layer MMS to create, edit, display and manage multimedia. When you create and send a MMS, you create a SlideshowModel, build a MediaModel,TextModel, etc., and add it to the SlideshowModel. When sending, SlideshowModel will take out the media files in it, convert them to PduPart and put them in PduBody. After receiving the message, take out the PduPart from the PduBody, restore it to a media file, generate MediaModel, and add it to the SlideshowModel, that is, restore to a slide. After the application gets the slide, it can be displayed and played.
Attachment Typ
With regard to attachment types, all MMS in Mms applications have a slide that contains all the attachment files. But Mms does some special processing, for a MMS message, its attachment types are divided into IMAGE, AUDIO, VIDEO, and SLIDESHOW, which can be seen from the list of add attachments dialog box, and the presentation is different. But there are not so many types in the actual implementation, there is only one SlideshowModel and all the attachments are in it. It deals with the rule that if only one media (image, audio and video) is added, the type will be set to the appropriate media type, and only when you explicitly choose to add slides in the attachment dialog box and multiple slides have been added, the attachment type will be a slide. This attachment type is only valid when adding attachments to MMS and before sending MMS, and is mainly used for how to display media files in the message list. If it is a specific media type, it is displayed directly, otherwise it is displayed as a slide. This attachment type only exists in the application to display media, and there is no trace in the Pdu sent out. When receiving the MMS, it is also based on the contents of the converted SlideshowModel to speculate the attachment type, and then do the display. Therefore, for a MMS, it always has a SlideshowModel, and the type of attachment that the user feels is only a processing above the attachment media display.
Create and edit MMS
Unlike traditional mobile phones, you don't need a special way to create a MMS. Because Mms applications do not make a strict distinction between MMS and SMS, but treat them as a message in a unified conversation, the difference between MMS and SMS is also very simple, depending on whether there is only an attachment (WorkingMessage.hasAttachment ()) in a message. Creating a MMS is also very simple, simply click on the Attach menu of Composer to add media. After selecting image, audio and video in the list, there is only one media file, which will go to other Activity to select the file, and then return its Uri to Composer,Composer. It will call WorkingMessage.setAttachment () to make specific additions, create MediaModel with Uri, then add it to SlideshowModel, and set the type. In addition, if you select the Attach slide, it will go directly to edit the slide, you can add and delete the slide page, add media files to the slide page, set the layout, etc., and then Composer will show the SlideshowModel, at this time the attachment type is also SLIDESHOW, these are done through WorkingMessage.load ().
After adding media to the slide, WorkingMessage will call back an interface onAttachmentChanged (), which is implemented by Composer, which is mainly used to notify Composer that the attachment has changed and refresh the UI to display the attachment correctly. Composer creates an AttachmentEditor to display the contents of the attachment, because all attachments are placed in the Slideshow and the Slideshow in the WorkingMessage can be obtained through WorkingMessage.getSlideshow (). AttachmentEditor will create different View according to the contents of Slideshow to show different attachments. If there is only one Video,Audio or Image in Slideshow, create VideoAttachmentView,AudioAttachmentView or ImageAttachmentView directly, and SlideshowAttachmentView will be created when the number of pages in the slide is greater than 1. There are corresponding buttons can be used to edit, replace or delete, for a single media to view / play, choose to view the original image and play audio video, replace can re-select an attachment, delete will remove the attachment; for Slideshow editing and delete, the editor will directly enter the slide editing page, where you can a page of each slide for detailed editing, delete will remove the attachment.
After editing the attachment, there are three ways to deal with it, one is to send a message, one is to save it as a draft and the other is to give up the message. Both sending messages and saving drafts package the slides, convert them to Pdu, and save them to the database, where the slides need to be loaded from the database and unpackaged Pdu into SlidehshowModel.
Packaging and unpackaging MMS
Before you send a message, or when you save a draft, you need to package the SlideshowModel into Pdu format and save it to the database. This is called MMS packaging (Packaging), is completed by the SlideshowModel.makePduBody () method, it will take out the contents of the slide one by one, into a PduPart, and then put into the PduBody to generate PduBody, a media corresponding to a PduPart, while you can also set the properties of PduPart to describe the media file, such as ContentType, which is a string used to identify the media MIME type; the name of the Filename file; the path of the ContentLocation file. This information is used to describe the meta-information (MetaData) of the data in PduPart, that is, what the data is, so that the data can be processed correctly when unpacking.
After that, PduPersister will store the PduBody in the database through its persist () method. It will write the descriptive information in PduPart as a database field, store the file under the TelephonyProvider folder (/ data/data / android.providers.telephony/app_parts), and write the stored path to the database as a _ data field, so that the data of a MMS will be written to the database. After that, the data of MMS is loaded from the database, so the database in the original SlideshowModel is no longer valid. For example, Uri may point to a file or other database in the original SlideshowModel, but it is no longer valid after PduPersister.persist ().
When PduPersister.persist (), MMS attachments are loaded from the data, PduPersister.load () will load the data from the database into a PduBody,SlideshowModel method createFromPduBody () is used to convert PduBody into a SlideshowModel, extract media information from PduPart to get the correct media format, and related information, you can get specific files (streams) through Uri.
The received MMS process is about the same when NotificationTransaction or RetrieveTransaction uses HttpUtils to obtain MMS data from MMSC, parses the data to generate Pdu using PduParser, writes it to the database with PduPersister.persist (), and then loads it from the database.
SMIL language support
Another very important data for each MMS is SMIL language. SMIL is the abbreviation of synchronous Multimedia Integration language (Synchronized Multimedia Integration Language). It is very similar to HTML documents and is a standard language for multimedia manipulation stipulated by W3C (World Wide Web Consortium). MMS also uses it to manage and play multimedia. Let's take a look at a specific Smil language example:
SMIL language usually plays multimedia page by page, which is very similar to illusory playback, because many SMIL players are in the form of slides. Because MMS uses SMIL to transmit multimedia, Mms terminals will play MMS in a slide show. This is why SlideshowModel comes out of Mms applications. Slide display MMS is a common method, even if some terminal applications do not display MMS by slide show, they all have page number identification for MMS sent by operators or MMS platforms, and other mobile phones, for example, non-smart phones also view MMS on a slide-by-page basis.
It mainly records the layout information used for slides. This SMIL language is used for slide layout, that is to say, SMIL will be like a HTML document layout web page to explain how to layout slides, it has these TAG:head, layout, body, par,head is the header information, there is TAG layout used to explain how the slide is laid out, specifically it uses some sub-TAG such as root-layout, region and so on to explain how each element in the slide, such as Image or Text, is laid out. TAG body lists all the media elements and details of the slide, such as image, audio, text, etc., each par is a page, its sub-TAG shows what the page contains, of course, there are a lot of content in SMIL language that can be explained on Wikipedia.
When packaging slides, that is, converting SlideshowModel to Pdu, it will generate a SMIL language based on the contents of SlideshowModel, generate SMIL documents through SmilHelper.getDocument (), add it to PduBody and act as * PduPart, its ContentType (MIME) is application/smil, and its content is SMIL documents. It is important to note that SMIL documents are always in the * Part of PduBody, and it writes the contents of the document directly to the PduPart, rather than as a file.
When unpacking, the SMIL document is first taken out, parsed, and a slide is generated.
Because SMIL is a standard document, the W3C has its corresponding specifications and libraries to parse and generate. We can see such two Package in Mms application: org.w3c.dom.* and com.android.mms.dom.*;, in which org.w3c.dom is some standard library of SMIL language, and com.android.mms.dom.*; is the implementation of some standard interfaces of org.w3c.dom, or some adaptations for Mms applications. Then some classes in com.android.mms.model.* are also written according to the SMIL standard. For example, SmilHelper is specially used to parse SMIL documents and generate SMIL documents. Of course, it will use the contents of the two Package mentioned above. For example, ImageModel,TextModel and RegionModel are also based on SMIL standards, for example, they correspond to the tags img, text and region in SMIL documents.
Of course, these are the implementation of specific terminal applications, different applications may have different ways, but what is sent and received should be a standard Pdu, and the SMIL document is just one of the PduPart.
Thank you for reading! This is the end of this article on "how to add attachment setattachment to MMS". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.