Question

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.
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).

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. I tried to switch the mute button of the iPad, and I also tried to change the SoundMixer.audioPlaybackMode to Media and Ambient. 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 ?

Was it helpful?

Solution

Maybe this problem is related to the iOS System.

In iOS perspective, as far as I know, officially it is not possible. 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. 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. most likely this reason.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top