how to detect that camera or mic is turned off on `onUserJoined` agora in react-native - react-native

In the agora, there are methods that detect when users turn off the audio (onRemoteAudioStateChanged) of video (onRemoteVideoStateChanged) streams while you are both on a call.
But when one user starts previewing and turns off the cam or mic and then joins a call is there any possibility to detect that on onUserJoined?

Related

Streaming RTMP with an overlay, react-native

I'm using https://github.com/NodeMedia/react-native-nodemediaclient to livestream to a server without issue, it's working as intended. But I'm wondering how I would go about if I wanted to send the camera feed with any type of overlay?
For example, livestreaming an football game and wanted to show a scoreboard or a clock to the user who is watching. Is this even possible?

Camera live View in apple watch

On 3/9 apple demo.
They show how to use apple watch to see the camera live view and open the garage door.
I think they should integrate with HomeKit to control the garage door,
but how to get the camera live view??
Do these live view images come from iphone app?
then using bluetooth to pass the image data to watch?
The iOS parent app to the Watch app most likely integrates with HomeKit to control the garage door and the webcam.
In order to display the images from the webcam on the Watch, they are most likely writing those images into the Shared App Group between the iOS app and the Watch Extension using MMWormhole or a similar approach. They then read the images from the App Group and push them to the Watch over bluetooth and WiFi using the WKInterfaceDevice addCachedImage(_:name:) method. Once the image is uploaded to the Watch, it can then displayed on the Watch using a WKInterfaceImage or WKInterfaceGroup background image.

How to close peerConnection in WebRtc

WebRtc sample
If I press call, allow/deny menu is shown in the upper screen. When I press allow, Chrome starts displaying red circle in the header which signals that microphone is active. All other sounds in others Chromes tabs are muted (for example youtube video).
When I press hang, red circle does not dissapears, youtube video in second tab is still muted. I have to press F5 to restore state which was before call.
Is there any PeerConnection to stop the call and stop mic recording ?
Yes, the reason the "red light" is still on is that the media tracks in the mediaStream object (called localstream on that particular page) gathered through getusermedia is still playing/active.
To close a media stream and thus release any hold on the local media inputs simply call localstream.stop() that will end the stream and stop accessing the local media input. This will stop all associated media tracks.
You can also do this by calling stop() on the individual media tracks(grabbed from getVideoTracks or getAudioTracks from the mediaStream).
As for other audio being turned down in other pages/apps. Here is the crbug handling that issue.
Side Note: if the media is being pushed through a peerConnection, then you will probably have to renegotiate the connection due to the mediaStream changing.

iOS how to don't stop music when the app start launching

I've noticed that when my app start, the music I'm listening is automatically stopped, and I've noticed that when I start some other apps, the music just continue... this means that I don't know how to manage the actual playing music in the device to let it plays or stop.
I'm developing a game with obj-c and cocos2d btw, I've searched but sadly I've found nothing... so here's my question, how can I let the music I'm listening with my device continue to play even if I start the app ?
edit: I'm using SimpleAudioEngine to start a background music and some sound effects in my app
Place this line in your application:didFinishLaunchingWithOptions: method of your AppDelegate or in general before using the audio player.
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
According to the documentation, the AVAudioSessionCategoryAmbient category is
for an app in which sound playback is nonprimary—that is, your app can
be used successfully with the sound turned off.
This category is also appropriate for “play along” style apps, such as a virtual piano that a user plays over iPod audio. When you
use this category, audio from other apps mixes with your audio. Your
audio is silenced by screen locking and by the Silent switch (called
the Ring/Silent switch on iPhone).
please import AVFoundation/AVFoundation.h
Swift:
Before playing enter this line:
let audioSession = AVAudioSession.sharedInstance()
if audioSession.otherAudioPlaying {
_ = try? audioSession.setCategory(AVAudioSessionCategoryAmbient, withOptions: AVAudioSessionCategoryOptions.MixWithOthers)
}
For people looking to solve this within react native (iOS)
My problem was quite the opposite where some of our muted videos with no music was causing background sound to be paused from other apps for no reason.
To fix this, also pass ignoreSilentSwitch="obey" prop alongside disableFocus and muted props through your Video component.
According to the docs:
You can activate the audio session at any time after setting its category, but it’s generally preferable to defer this call until your app begins audio playback. Deferring the call ensures that you won’t prematurely interrupt any other background audio that may be in progress.
Be sure not to be starting the audio session directly via its setActive method or indirectly via AVAudioEngine or other playback engine(s) immediately after the app launches. You should set only the category at this stage if you don't want your app to interrupt others on launch. If you're using AVAudioEngine, defer setting up the engine or connecting anything to the engine's mainMixerNode or outputNode until you actually need to start playing something.
When your app starts playing music, it will pause any audio currently playing. For obvious reasons. If you want your music to carry on playing when the app launches then don't let the app play any music.

How can I prevent my application (using AVPlayer) is muted when the ringtone is muted?

The topic may sound strange, but please keep reading on.
I am using AVPlayer to play some sound from the iPod library and everything works fine when using it with headphones plugged in, but when I want to use the app to play from the built in speakers there is no sound output. (The time counter and everything else in the application is still working like there would be sound output. Like it is just muted.)
I checked the volume and the mute lock and then found out that the ringtone was muted. But ringtone muting doesn't affect other applications like the iPod app itself or the Spotify music app.
How can I prevent my application (using AVPlayer) is muted when the ringtone is muted and behave like other music player apps?
You should set your app's audio session to AVAudioSessionCategoryPlayback. From the docs:
Use this category for an
application whose audio playback is of primary importance. Your audio
plays even with the screen locked and with the Ring/Silent switch set
to silent.