MMs. uri 到 MediaModel . 彩信的各种mediaModel

彩信的媒体大概是这样:
WorkingMessage里有个SlideshowModel
SlideshowModel里一队列SlideModel
SlideModel 是一个队列的MediaModel
MediaModel,可以衍生出AudioModel,RegionMediaModel。
RegionMediaModel包含TextModel,ImageModel,VideoModel这三个分类。

创建MediaModel的构造函数
    public MediaModel(Context context, String tag, String contentType,
            String src, Uri uri) throws MmsException {
        mContext = context;
        mTag = tag;
        mContentType = contentType;
        mSrc = src;
        mUri = uri;
        initMediaSize();
        mMediaActions = new ArrayList<MediaAction>();
    }


    public MediaModel(Context context, String tag, String contentType,
            String src, byte[] data) {
        if (data == null) {
            throw new IllegalArgumentException("data may not be null.");
        }

        mContext = context;
        mTag = tag;
        mContentType = contentType;
        mSrc = src;
        mData = data;
        mSize = data.length;
        mMediaActions = new ArrayList<MediaAction>();
    }


    public MediaModel(Context context, String tag, String contentType,
            String src, DrmWrapper wrapper) throws IOException {
        mContext = context;
        mTag = tag;
        mContentType = contentType;
        mSrc = src;
        mDrmObjectWrapper = wrapper;
        mUri = DrmUtils.insert(context, wrapper);
        mSize = wrapper.getOriginalData().length;
        mMediaActions = new ArrayList<MediaAction>();
    }


mediaModel里面比较重要的的几个成员:
protected String mTag;
protected String mSrc;
protected String mContentType;
private Uri mUri;
private byte[] mData;
protected int mSize;


Tag是类型标签。在SmilHelper里。
    public static final String ELEMENT_TAG_TEXT = "text";
    public static final String ELEMENT_TAG_IMAGE = "img";
    public static final String ELEMENT_TAG_AUDIO = "audio";
    public static final String ELEMENT_TAG_VIDEO = "video";
    public static final String ELEMENT_TAG_REF = "ref";

mSrc 文件名
mContentType在frameworks/base/core/java/com/google/android/mms/ContentType里定义,比如
public static final String TEXT_PLAIN        = "text/plain";
    public static final String TEXT_HTML         = "text/html";
public static final String IMAGE_JPEG        = "image/jpeg";
    public static final String IMAGE_JPG         = "image/jpg";
public static final String VIDEO_UNSPECIFIED = "video/*";
    public static final String VIDEO_3GPP        = "video/3gpp";

uri不说了。
data 是byte[] 的数据
size是文件长度。


彩信的单个附件的uri,
从onActivityResult得到。


像拍照片的uri来的最容易,是Uri uri = Uri.fromFile(file);
  是已经有了file,再来得到uri..太邪恶了!

你可能感兴趣的:(html,android,Google)