当前位置:网站首页>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
边栏推荐
- ./ setup. Insufficient sh permission
- Inftnews | web5 vs Web3: the future is a process, not a destination
- Redhat下安装fedora
- 网络安全-CSRF
- iNFTnews | Web5 vs Web3:未来是一个过程,而不是目的地
- How to operate DTC community?
- Gee (IV): calculate the correlation between two variables (images) and draw a scatter diagram
- Advantages and disadvantages of rest ful API
- Exploratory data analysis of heartbeat signal
- Unity3D学习笔记6——GPU实例化(1)
猜你喜欢
Develop those things: go plus c.free to free memory, and what are the reasons for compilation errors?
消费品企业敏捷创新转型案例
Database daily question --- day 22: last login
GEE(四):计算两个变量(影像)之间的相关性并绘制散点图
Introduction to redis and jedis and redis things
微信论坛交流小程序系统毕业设计毕设(3)后台功能
Adults have only one main job, but they have to pay a price. I was persuaded to step back by personnel, and I cried all night
Use JfreeChart to generate curves, histograms, pie charts, and distribution charts and display them to jsp-2
Wechat forum exchange applet system graduation design completion (8) graduation design thesis template
USB(十五)2022-04-14
随机推荐
二叉树(Binary Tree)
位运算(Bit Operation)
2021-01-11
Digital collections accelerated out of the circle, and marsnft helped diversify the culture and tourism economy!
How to operate DTC community?
UE4_UE5结合罗技手柄(F710)使用记录
JMeter-接口自动化测试读取用例,执行并结果回写
opencv scalar传入三个参数只能显示黑白灰问题解决
USB (十七)2022-04-15
Wechat forum exchange applet system graduation design (5) assignment
Wechat forum exchange applet system graduation design completion (4) opening report
Brush question 5
I wish you all the best and the year of the tiger
QT graphicsview graphical view usage summary with flow chart development case prototype
Gee (IV): calculate the correlation between two variables (images) and draw a scatter diagram
Network security -beef
每日一题——PAT乙级1002题
Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020
网络安全-联合查询注入
Introduction to anomaly detection