Expand my Community achievements bar.

SOLVED

WebCamera + Audio: Audio often doesn't work or not audible (just noise)

Avatar

Level 2

Hi,

I'm building a simple audio/video component using the WebCamera pod and the Audio subscriber/publisher components. What I want is to publish the audio and video streams at the same time, with one action. I've try to override the startWebcam function of the WebCamera pod to publish my audio, but sometimes it works, sometimes I don't hear anything, and sometimes the sound is simply not audible (lots of noise, can't hear a word). I've also tried to publish my audio first on the creationComplete of the ConnectSessionContainer, with the same results. It seems like to many things are happening at the same time, confusion between streams, ...

What would be the best way to start audio/video stream simultaneously?

Thanks!

Matetnic

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Hi,

I am not sure why you are calling it in onStreamReceive. What you should do ideally is having components such as WebcamPublisher and WebcamSubscriber and also AudioPublisher and AudioSubscriber, something like

<rtc:WebcamPublisher id="webcamPub" />

<rtc:WebcamSubscriber webcamPublisher="" width="400" height="400" />

<rtc:AudioSubscriber id="audioSub" />

<rtc:AudioPublisher id="audioPub" />

<rtc:Button click="onClick(event)" />

Private function onClick(p_evt:MouseEvent):void

{

audioPub.publish();

webcamPub.publish();

}

And in case you are using WebCamera Class , you would have to subclass startWebcam() function of WebCamera and put the audioPub.publish() function inside it. Since you are doing these customizations, its always recommended to use WebcamPublisher and WebcamSubscriber classes instead of using the WebCamera pod class.

Lastly when you say you can't hear audio, what are you getting inside AudioPublisher's onStreamReceive on win 7 64 bit, also are you creating the stream in that function and so on. Have you tried debugging by linking to the source ?

Hope these gives you pointers to get into more details and provide to us for further investigation.

Thanks

Regards

Hironmay Basu

View solution in original post

4 Replies

Avatar

Former Community Member

Hi,

Our audio and video streams are handled separately through Audio Pub/Sub and Webcam Pub/Sub components and if you call the functions for starting audio and video at same time, there shouldn't be issues unless you have very low bandwidth and people have been using it.

If you want to start them together, in one click of a button you can call the start() function both in AudioPublisher and WebcamPublisher in the button's click handler.

Internally, both the Audio and Webcam calls the streamManager's functions such as createStream, publishStream and so on, however, you don't need to go down to that level and you should deal only at the Audio Pub/sub and Webcam Pub/Sub component level.

Hope this helps

Thanks

Hironmay Basu

Avatar

Level 2

Hi,

Thanks for quick response. Unfortunately, I still have the same issue, but here are some more details :

- Here is my code: <rtc:WebCamera id="webCamera" streamReceive="audioPub.publish();" />

- First, I click "Start my Camera"

- When the publish() executes, I have no error but I can't hear anything and my microphone doesn't work either

- Closing the Flex application and trying the microphone with another program like Sound Recorder gives me an error (it was working before)

- Trying the speakers with YouTube doesn't work either (no sound)

- I also check if the user is still hook in the room, delete him if so, but with no effect

- I can't get no more audio from my PC, have to reboot to make it works again

- IMPORTANT: My problem occurs on Windows 7 64 bits, I've tried with Windows XP and I don't have the problem

- If I use a separate button to publish the audio, then it works fine

Using this pattern, I can reproduce it everytime.

Is there a security check that disallow a Flash program to start the use of the microphone/webcam without an explicit action from the user (e.g. click of a button) ? I remember having hear something like that...

Any idea?

Thanks!

Matetnic

Avatar

Level 2

Hi,

After several tests, we finally found the problem. It was coming from the USB Bandwidth usage, that was going too high on the Win7 PC. That was causing my USB headset to crash. Reducing the bandwidth usage of my webcam (which was 62% initially) solves the problem.

Thanks for you help!

matetnic

Avatar

Correct answer by
Former Community Member

Hi,

I am not sure why you are calling it in onStreamReceive. What you should do ideally is having components such as WebcamPublisher and WebcamSubscriber and also AudioPublisher and AudioSubscriber, something like

<rtc:WebcamPublisher id="webcamPub" />

<rtc:WebcamSubscriber webcamPublisher="" width="400" height="400" />

<rtc:AudioSubscriber id="audioSub" />

<rtc:AudioPublisher id="audioPub" />

<rtc:Button click="onClick(event)" />

Private function onClick(p_evt:MouseEvent):void

{

audioPub.publish();

webcamPub.publish();

}

And in case you are using WebCamera Class , you would have to subclass startWebcam() function of WebCamera and put the audioPub.publish() function inside it. Since you are doing these customizations, its always recommended to use WebcamPublisher and WebcamSubscriber classes instead of using the WebCamera pod class.

Lastly when you say you can't hear audio, what are you getting inside AudioPublisher's onStreamReceive on win 7 64 bit, also are you creating the stream in that function and so on. Have you tried debugging by linking to the source ?

Hope these gives you pointers to get into more details and provide to us for further investigation.

Thanks

Regards

Hironmay Basu

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----