当前位置:网站首页>Solution: prompt "unsupported video format" when inserting avi format video into the message
Solution: prompt "unsupported video format" when inserting avi format video into the message
2022-07-07 23:14:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
【 Test steps 】: New information . Join in AVI Format video
【 Test results 】: A prompt pops up when you join “unsupported video format”
This problem mainly refers to the fact that nowadays Mobile MMS video attachments do not support this AVI Video format , So we track the code through the operation process , lookup “unsupported video format” Where it's produced .
We start from the add attachment interface ComposeMessageActivity Class onActivityResult() Method start .
–》onActivityResult() The calling code is as follows :
case REQUEST_CODE_ATTACH_VIDEO: if (data != null) { mAttachFileUri = data.getData(); addVideoAsync(mAttachFileUri, false); } break;
–》addVideo()–》setAttachment()<WorkingMessage.java> The calling code is as follows :
result = append ? appendMedia(type, dataUri, slideShowEditor) : changeMedia(type, dataUri, slideShowEditor);
–》changeMedia()–》internalChangeMedia()–》changeVideo()<SlideshowEditor.java>
–》new VideoModel()<TAG 1-1>
public VideoModel(Context context, Uri uri, RegionModel region) throws MmsException { this(context, null, null, uri, region); initModelFromUri(uri); checkContentRestriction(); }
–》initModelFromUri()<VideoModel.java> The calling code is as follows :
private void initModelFromUri(Uri uri) throws MmsException { String scheme = uri.getScheme(); if (scheme.equals(“content”)) { initFromContentUri(uri); } else if (uri.getScheme().equals(“file”)) { initFromFile(uri); } initMediaDuration(); }
The above code is added by Log For the output , there scheme The value of is “file”.
–》initFromFile()
private void initFromFile(Uri uri) throws MmsException { String path = uri.getPath(); mSrc = path.substring(path.lastIndexOf(‘/’) + 1); MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton(); String extension = MimeTypeMap.getFileExtensionFromUrl(mSrc); if (TextUtils.isEmpty(extension)) { // getMimeTypeFromExtension() doesn’t handle spaces in filenames nor can it handle // urlEncoded strings. Let’s try one last time at finding the extension. int dotPos = mSrc.lastIndexOf(‘.’); if (0 <= dotPos) { extension = mSrc.substring(dotPos + 1); } } mContentType = mimeTypeMap.getMimeTypeFromExtension(extension.toLowerCase()); // It’s ok if mContentType is null. Eventually we’ll show a toast telling the // user the video couldn’t be attached. if (TextUtils.isEmpty(mContentType)) { throw new MmsException(“Type of media is unknown.”); }
if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) { Log.v(TAG, “New VideoModel initFromFile created:” + ” mSrc=” + mSrc + ” mContentType=” + mContentType + ” mUri=” + uri); } }
In the above code mContentType Assign a value , Here we go through Log Output ,mContentType The value of is “video/x-msvideo”.
Next, proceed to the constructor <TAG1-1> The method in checkContentRestriction().
protected void checkContentRestriction() throws ContentRestrictionException { ContentRestriction cr = ContentRestrictionFactory.getContentRestriction(); cr.checkVideoContentType(mContentType); }
–》checkVideoContentType()<CarrierContentRestriction.java>
public void checkAudioContentType(String contentType) throws ContentRestrictionException { if (null == contentType) { throw new ContentRestrictionException(“Null content type to be check”); }
if (!sSupportedAudioTypes.contains(contentType)) { throw new UnsupportContentTypeException(“Unsupported audio content type : “ + contentType); } }
The code marked in bold in the above code is the problem of test description . We then analyze the code in the static statements in this class .
sSupportedVideoTypes = ContentType.getVideoTypes();
Finally, we finally arrived ContentType.java class , And it is found that there is no support for this video format in this class . So add the following code to support .
……
public static final String VIDEO_UNSPECIFIED = “video/*”; public static final String VIDEO_3GPP = “video/3gpp”; public static final String VIDEO_3G2 = “video/3gpp2”; public static final String VIDEO_H263 = “video/h263”; public static final String VIDEO_MP4 = “video/mp4”; public static final String VIDEO_X_MSVIDEO = “video/x-msvideo”;
……
// add supported video types sSupportedVideoTypes.add(VIDEO_X_MSVIDEO); sSupportedVideoTypes.add(VIDEO_3GPP); sSupportedVideoTypes.add(VIDEO_3G2); sSupportedVideoTypes.add(VIDEO_H263); sSupportedVideoTypes.add(VIDEO_MP4);
……
OK!
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/116200.html Link to the original text :https://javaforall.cn
边栏推荐
猜你喜欢
Are the microorganisms in the intestines the same as those on the skin?
STL标准模板库(Standard Template Library)一周学习总结
Personal statement of testers from Shuangfei large factory: is education important for testers?
Innovation today | five key elements for enterprises to promote innovation
Gee (IV): calculate the correlation between two variables (images) and draw a scatter diagram
Interview questions: how to test app performance?
V20变频器手自动切换(就地远程切换)的具体方法示例
Specific method example of V20 frequency converter manual automatic switching (local remote switching)
Develop those things: go plus c.free to free memory, and what are the reasons for compilation errors?
微信论坛交流小程序系统毕业设计毕设(6)开题答辩PPT
随机推荐
30讲 线性代数 第五讲 特征值与特征向量
What are the similarities and differences between smart communities and smart cities
Locate to the bottom [easy to understand]
Interview questions: how to test app performance?
How to operate DTC community?
网格(Grid)
Talk about DART's null safety feature
Inftnews | the wide application of NFT technology and its existing problems
成年人只有一份主业是要付出代价的,被人事劝退后,我哭了一整晚
海内外技术人们“看”音视频技术的未来
USB (十八)2022-04-17
DTC社群运营怎么做?
微信论坛交流小程序系统毕业设计毕设(1)开发概要
Use JfreeChart to generate curves, histograms, pie charts, and distribution charts and display them to jsp-2
今日创见|企业促进创新的5大关键要素
Quelles sont les similitudes et les différences entre les communautés intelligentes et les villes intelligentes?
Adrnoid开发系列(二十五):使用AlertDialog创建各种类型的对话框
网络安全-CSRF
Gee (III): calculate the correlation coefficient between two bands and the corresponding p value
【刷题记录】3. 无重复字符的最长子串