====== onLocalMedia() ====== wrtc.onLocalMedia() is an event function called when the wrtc object got access to local media (local microphone/camera), released access (media stream stopped), or failed to get access. Depending on wrtc object configuration it may try to get access to local media at once when page is loaded, or later on when making or receiving a call. You can use this event to enable and disable video window showing image of local camera, or warn user that camera could not be accessed. An access failure usually is because browser was denied access. It can have multiple reasons: * page not opened using HTTPS - some browsers demand HTTPS access to be able to get access to mic/cam * user denied access - some browsers display a pop-up asking user for permission to access mic/cam. If user denies access wrtc.onLocalMedia(false) will occur * some browsers remember pages user has denied mic/cam access to once and blocks all future access requests too. User then need to remove the block (usually shown as a crosser over camera in browser's URL field) * mic/cam already in use - some browsers can only get access if no other program or webpage is using the mic or cam * requested [[ixnx:wrtc:js:api:wrtc:audiosource|wrtc.audioSource]] or [[ixnx:wrtc:js:api:wrtc:videosource|wrtc.videoSource]] does not exist ===== Occurs ===== wrtc_kit has got or released access to local media (mic/cam) or failed to do so ===== Arguments ===== wrtc.onLocalMedia(arg) * arg: * "request" - requested access to local media (mic/cam) * "success" - got access to local media * "stop" - stopped accessing local media * "error" - failed to get access to local media ===== Return value ===== Ignored. ===== Example ===== wrtc.onLocalMedia = function(arg) { if (arg == "success") wrtc.localVideo.style.display = "inline"; else if (arg == "error") window.alert("Could not access mic/cam"); else wrtc.localVideo.style.display = "none"; }