bugfix:录音的时候,webview不能播放视频
来源:互联网 发布:淘宝舞蹈服 编辑:程序博客网 时间:2024/05/22 00:25
现象:
使用webview显示html,html中有播放视频,同时设备正在录音。
模拟器中没有问题,录音可以生成,视频也可以播放。
但是真机中,录音可以生成,但是视频无法播放。
真机中报错:
[0x3b05518c] Received corrupt data. Property list is NULLERROR: [0x3b05518c] AVAudioSessionUtilities.h:88: GetProperty_DefaultToZero: AudioSessionGetProperty ('tfac') failed with error: 'tahw'
原因:
根据报错信息,找到一篇文章:
http://stackoverflow.com/questions/22222501/audiosessiongetproperty-tfac-failed-with-error-tahw
// Configure audio session[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
其中提到了AVAudioSession这个类。
查看下项目中对应的代码,由于录音的时候,没有考虑播放的问题,所以项目中直接使用的AVAudioSessionCategoryRecord
AVAudioSession *session = [AVAudioSession sharedInstance];NSError *sessionError;[session setCategory:AVAudioSessionCategoryRecord error:&sessionError];
这就是导致录音时,不能播放视频的原因了。
解决办法:
查看AVAudioSessionCategory其他的值:
#pragma mark -- Values for the category property --/* Use this category for background sounds such as rain, car engine noise, etc. Mixes with other music. */AVF_EXPORT NSString *const AVAudioSessionCategoryAmbient;/* Use this category for background sounds. Other music will stop playing. */AVF_EXPORT NSString *const AVAudioSessionCategorySoloAmbient;/* Use this category for music tracks.*/AVF_EXPORT NSString *const AVAudioSessionCategoryPlayback;/* Use this category when recording audio. */AVF_EXPORT NSString *const AVAudioSessionCategoryRecord;/* Use this category when recording and playing back audio. */AVF_EXPORT NSString *const AVAudioSessionCategoryPlayAndRecord;/* Use this category when using a hardware codec or signal processor while not playing or recording audio. */AVF_EXPORT NSString *const AVAudioSessionCategoryAudioProcessing;/* Use this category to customize the usage of available audio accessories and built-in audio hardware. For example, this category provides an application with the ability to use an available USB output and headphone output simultaneously for separate, distinct streams of audio data. Use of this category by an application requires a more detailed knowledge of, and interaction with, the capabilities of the available audio routes. May be used for input, output, or both. Note that not all output types and output combinations are eligible for multi-route. Input is limited to the last-in input port. Eligible inputs consist of the following:AVAudioSessionPortUSBAudio, AVAudioSessionPortHeadsetMic, and AVAudioSessionPortBuiltInMic. Eligible outputs consist of the following: AVAudioSessionPortUSBAudio, AVAudioSessionPortLineOut, AVAudioSessionPortHeadphones, AVAudioSessionPortHDMI, and AVAudioSessionPortBuiltInSpeaker. Note that AVAudioSessionPortBuiltInSpeaker is only allowed to be used when there are no other eligible outputs connected. */AVF_EXPORT NSString *const AVAudioSessionCategoryMultiRoute NS_AVAILABLE_IOS(6_0);
根据需要同时录音、播放视频的需求,改为:
AVAudioSession *session = [AVAudioSession sharedInstance];NSError *sessionError;[session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:&sessionError];
参考资料:
http://stackoverflow.com/questions/22222501/audiosessiongetproperty-tfac-failed-with-error-tahw
iOS AudioSession详解
0 0
- bugfix:录音的时候,webview不能播放视频
- android 4.0以上WebView不能全屏播放视频的解决办法
- android 4.0以上WebView不能全屏播放视频的解决办法
- WebView播放视频的问题
- 当webView关闭的时候,音乐或者视频还在播放,没有停止
- Android的Media(录音,播放音乐,播放视频等)
- Android Webview中解决H5的音视频不能自动播放的问题
- Android Webview中解决H5的音视频不能自动播放的问题
- 关于Android中使用WebView播放网络视频不能全屏的问题
- WebView无法播放视频的解决办法
- WebView播放HTML5视频,黑屏的问题。
- webview全屏播放html5的视频
- Android的WebView如何播放视频
- Android的WebView中如何播放视频
- 解决webView无法播放视频的问题
- IOS多媒体之视频播放与录音的简易实现
- 1.QT中播放视频,录音程序的编写
- WebView播放视频
- 火力篮球游戏源码完整版--采用标准的游戏开发文档
- java中import两种导入类型比较
- 程序员准备面试时常犯的10个错误
- 图的邻接表的数组实现及其应用
- Android笔记-ListView总结(多选框ListViiew,动态加载,多线程更新ListView中的进度条)
- bugfix:录音的时候,webview不能播放视频
- fastjson 序列化部分源码解析②
- 科普:什么样的电子合同才合法有效?
- windows配置环境变量
- 关于c中可变参数的一点学习
- Android SharedPreferences用法及程序共享机制
- 大型网站架构改进历程:存储的瓶颈(1)
- Arcpy MXD发布服务
- 点到平面的距离公式推导