当前位置:网站首页>解决:信息中插入avi格式的视频时,提示“unsupported video format”
解决:信息中插入avi格式的视频时,提示“unsupported video format”
2022-07-07 21:50:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
【測试步骤】:新建信息。加入AVI格式的视频
【測试结果】:加入时弹出提示“unsupported video format”
该问题主要提如今手机彩信视频附件不支持该AVI格式的视频,因此我们通过操作流程对代码进行追踪,查找“unsupported video format”产生的位置。
我们从加入附件界面ComposeMessageActivity类的onActivityResult()方法開始。
–》onActivityResult()调用代码例如以下:
case REQUEST_CODE_ATTACH_VIDEO: if (data != null) { mAttachFileUri = data.getData(); addVideoAsync(mAttachFileUri, false); } break;
–》addVideo()–》setAttachment()<WorkingMessage.java> 调用代码例如以下:
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> 调用代码例如以下:
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(); }
上述代码通过加入Log进行输出,这里的scheme的值为“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); } }
上述代码中对mContentType进行赋值,这里我们通过Log输出,mContentType的值为“video/x-msvideo”。
接下来接着进行构造函数<TAG1-1>中的方法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); } }
上述代码中加粗标识的代码就是測试描写叙述的问题。我们接着分析本类中静态语句快中的代码。
sSupportedVideoTypes = ContentType.getVideoTypes();
终于我们终于到ContentType.java类,而且发现该类中没有加入对该视频格式的支持。因此加入下面代码进行支持。
……
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!
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/116200.html原文链接:https://javaforall.cn
边栏推荐
- Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020
- 2022 words for yourself
- 每日一题——PAT乙级1002题
- 肠道里的微生物和皮肤上的一样吗?
- Brush question 3
- Are the microorganisms in the intestines the same as those on the skin?
- 网络安全-对操作系统进行信息查询
- 开发那些事儿:Go加C.free释放内存,编译报错是什么原因?
- Early childhood education industry of "screwing bar": trillion market, difficult to be a giant
- 网络安全-CSRF
猜你喜欢
What is fake sharing after filling the previous hole?
微信论坛交流小程序系统毕业设计毕设(2)小程序功能
安踏DTC | 安踏转型,构建不只有FILA的增长飞轮
微生物健康網,如何恢複微生物群落
[record of question brushing] 3 Longest substring without duplicate characters
I wish you all the best and the year of the tiger
Develop those things: go plus c.free to free memory, and what are the reasons for compilation errors?
行测-图形推理-1-汉字类
iNFTnews | NFT技术的广泛应用及其存在的问题
Unity and webgl love each other
随机推荐
微信论坛交流小程序系统毕业设计毕设(7)中期检查报告
Use JfreeChart to generate curves, histograms, pie charts, and distribution charts and display them to JSP-1
Gbu1510-asemi power supply special 15A rectifier bridge gbu1510
QT graphicsview graphical view usage summary with flow chart development case prototype
消息队列与快递柜之间妙不可言的关系
网络安全-beef
Software evaluation center ▏ what are the basic processes and precautions for automated testing?
[record of question brushing] 3 Longest substring without duplicate characters
微信论坛交流小程序系统毕业设计毕设(8)毕业设计论文模板
The author of LinkedList said he didn't use LinkedList himself
Unity dynamically merges mesh textures
面试百问:如何测试App性能?
二叉树(Binary Tree)
Are the microorganisms in the intestines the same as those on the skin?
Cases of agile innovation and transformation of consumer goods enterprises
V20变频器手自动切换(就地远程切换)的具体方法示例
行测-图形推理-5-一笔画类
Microbial health network, how to restore microbial communities
Software test classification
Handling file exceptions