Cordova Media Plugin打破了iOS上的HTML5音频标签 [英] Cordova Media Plugin breaks HTML5 Audio tag on iOS

查看:130
本文介绍了Cordova Media Plugin打破了iOS上的HTML5音频标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究离子应用程序,现在面临一个奇怪的问题。

I am working on an Ionic Application and now facing a curious issue.

在视图上,我可以录制音频。在同一个视图中我有很多HTML5音频标签。

On a view, i can record audio. On that same view i have many HTML5 audio tags.

音频标签运行良好,直到我发布一条记录。一旦执行了startRecord,我就不能再播放HTML5音频了。播放按钮不起任何作用。录制的音频录制得很好并重新启动我的应用程序,我可以播放它,就像页面上的其他音频一样。

The audio tag works well until i launch a record. Once startRecord is executed, i can't play the HTML5 audio no more. The play button doesn't do anything. The recorded audio is well recorded and restarting my application, i can play it, as for the other audio on the page.

我在Android上没有这个问题。

I don't have that problem on Android.

我认为我做得很好(我已经在iOS上看到你必须使用HTML5 APi在filesytem上创建文件,我做的没有成功) ,我在录制后发布了媒体(但问题甚至发生在stopRecord之前)。

I do every thing well i think (i have read that on iOS you have to create the file on the filesytem using the HTML5 APi, what i did with no success), i release the media after recording (but the issue happen even before the stopRecord).

有人遇到过这个问题吗?任何线索?

Did someone ever had that issue ? Any clue ?

Cordova:5.1.1
插件媒体:1.0.2
iOS:8.3

Cordova : 5.1.1 Plugin Media : 1.0.2 iOS : 8.3

问候,

推荐答案

返回解决方案。

在文件cordova-plugin-media / blob / master / src / ios / CDVSound.m中,应用以下补丁:

In file cordova-plugin-media/blob/master/src/ios/CDVSound.m, apply the following patch :

// get the audioSession and set the category to allow recording when device is locked or ring/silent switch engaged
         if ([self hasAudioSession]) {
             if (![self.avSession.category isEqualToString:AVAudioSessionCategoryPlayAndRecord]) {
             -                    [self.avSession setCategory:AVAudioSessionCategoryRecord error:nil];
             +                    [self.avSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
             }

             if (![self.avSession setActive:YES error:&error]) {

基本上在更改我们的AvAudioSession类别时,我们必须将其设置为Play And Record类别,而不仅仅是Record并添加与其他音频会话混合选项。

Basically while changing our AvAudioSession catagory, we have to put it in category 'Play And Record', not only 'Record' and add option 'to mix with others audio sessions'.

希望这会有所帮助;)

这篇关于Cordova Media Plugin打破了iOS上的HTML5音频标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆