当前位置:网站首页>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
边栏推荐
猜你喜欢
Wechat forum exchange applet system graduation design (2) applet function
STL标准模板库(Standard Template Library)一周学习总结
Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020
Software test classification
数字藏品加速出圈,MarsNFT助力多元化文旅经济!
聊聊支付流程的设计与实现逻辑
GEE(四):计算两个变量(影像)之间的相关性并绘制散点图
微信论坛交流小程序系统毕业设计毕设(4)开题报告
When copying something from the USB flash disk, an error volume error is reported. Please run CHKDSK
Wechat forum exchange applet system graduation design completion (7) Interim inspection report
随机推荐
Why does the market need low code?
嵌入式音频开发中的两种曲线
Oracle-数据库的备份与恢复
30讲 线性代数 第五讲 特征值与特征向量
Gbu1510-asemi power supply special 15A rectifier bridge gbu1510
opencv scalar传入三个参数只能显示黑白灰问题解决
kubernetes的简单化数据存储StorageClass(建立和删除以及初步使用)
成年人只有一份主业是要付出代价的,被人事劝退后,我哭了一整晚
I wish you all the best and the year of the tiger
Are the microorganisms in the intestines the same as those on the skin?
Brush question 5
网络安全-beef
Txt file virus
PMP项目管理考试过关口诀-1
Two kinds of curves in embedded audio development
Specific method example of V20 frequency converter manual automatic switching (local remote switching)
小程序多种开发方式对比-跨端?低代码?原生?还是云开发?
Network security - joint query injection
智慧社區和智慧城市之間有什麼异同
Introduction to anomaly detection