简体   繁体   English

iOS上的Air中的本机视频停止声音和麦克风

[英]Native video in Air on iOS stopping sound and microphone

I'm trying to play a native video in a StageWebView in an Air for iPad app that plays sound and requires user interaction via the microphone. 我正在尝试在Air for iPad应用程序的StageWebView中播放本地视频,该视频播放声音并需要用户通过麦克风进行交互。
Everything seems to work, but when I start playing the video, sound and microphone stop. 一切似乎正常,但是当我开始播放视频时,声音和麦克风停止。 If I dispose the StageWebView , sound and mic get back but only after 15 seconds (and I need sound and mic to work at least straight after the StageWebView is released). 如果我StageWebView ,则声音和麦克风只能在15秒后恢复(并且我需要声音和麦克风才能在StageWebView发行后至少可以直接工作)。

I tried to get this work on an iOS5 iPad1, and on an iOS6 iPad2, using Air 3.4, 3.5 and 3.6 beta. 我尝试使用Air 3.4、3.5和3.6 beta在iOS5 iPad1和iOS6 iPad2上完成此工作。 I tried to switch the mute button of the iPad, and I also tried to change the SoundMixer.audioPlaybackMode to Media and Ambient . 我试图切换iPad的静音按钮,也尝试将SoundMixer.audioPlaybackMode更改为MediaAmbient But it didn't worked and I'm stucked. 但这没有用,我被困住了。

Here is my code that deals with the microphone : 这是我处理麦克风的代码:

var microphone:Microphone = Microphone.getMicrophone();
microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, __micHandler);

private function micHandler(event : SampleDataEvent) : void {
    trace("mic is working !");
}

For the audio : 对于音频:

_snd = new Sound();
_snd.load(new URLRequest(path));
_sndChannel = _snd.play();

private function soundStopHandler(event : MouseEvent) : void {
    if(_sndChannel) _sndChannel.stop();
}

And for the video player : 对于视频播放器:

_webview = new StageWebView();
_webview.stage = stage;
_webview.viewPort = new Rectangle(10, 120, 480, 300);
_webview.loadURL(path);

private function videoStopHandler(event : MouseEvent) : void {
    if(_webview) {
        _webview.dispose();
        _webview = null;
    }
}

Did anyone faced this problem before me ? 有人在我面前遇到过这个问题吗? Is there anything I forgot or did in a wrong way ? 我有什么忘记或做错了什么吗?

Maybe this problem is related to the iOS System. 也许这个问题与iOS系统有关。

In iOS perspective, as far as I know, officially it is not possible. 以iOS的角度来看,据我所知,这是不可能的。 When you start the recording sessions, except for recording does not occupy it. 当您开始录制会话时,除了录制不会占用它。 Once you playback and recording sessions in the session must be solved. 一旦回放和录制会话中的会话,就必须解决。 recording and playback session, the session can not be occupied simultaneously. 录制和回放会话时,不能同时占用该会话。

refer a apple documentation: Audio Session 请参阅苹果文档: 音频会话

AVAudioSessionCategoryPlayAndRecord or the equivalent kAudioSessionCategory_PlayAndRecord—Use this category for an application that inputs and outputs audio. AVAudioSessionCategoryPlayAndRecord或等效的kAudioSessionCategory_PlayAndRecord-使用此类别输入和输出音频的应用程序。 The input and output need not occur simultaneously, but can if needed. 输入和输出不必同时发生,但可以在需要时发生。 This is the category to use for audio chat applications. 这是用于音频聊天应用程序的类别。

In AIR, if you code no problem. 在AIR中,如果您编写代码没问题。 most likely this reason. 最有可能是这个原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM