Auto start webcam on page load

Hello!

how to automatic start webcam capture on page load without the Start btn?

We have attempt many ways like
<script type="text/javascript">
$(document).ready(function(){
$("#publishBtn").trigger('click');
});
</script>

Without succcess.

Thanks!
 

Max

Administrator
Staff member
1. Somebody should allow camera and microphone first time.
2. You have to connect then publish.

Code:
$(document).ready(function(){
    try {
        Flashphoner.init();
    } catch (e) {
        console.error(e);
        return;
    }
    Flashphoner.createSession({urlServer: url}).on(SESSION_STATUS.ESTABLISHED, function (session) {
        session.createStream({name:"stream1"}).publish();
    });
});
 
SOLVED:

<script type="text/javascript">
time = 15,
interval = setInterval(function() {
time--;
document.getElementById('Label1').innerHTML = "Auto Start: " + time + ""
if (time == 0) {

document.getElementById("Label1").style.display = "none";

// stop timer
clearInterval(interval);
// click
document.getElementById('publishBtn').click();
}
}, 1000)
</script>
 
Top