Very Simple WebRTC Conference

Mnimalistic conference built on top of Bistri WebRTC API

by bistri

HTML

<script src="https://api.bistri.com/bistri.conference-3.3.3.js"></script>

JavaScript

/*
    JS library reference:
    http://developers.bistri.com/webrtc-sdk/js-library-reference
*/

onBistriConferenceReady = function ()
{  
    bc.init ( {
        appId: "38077edb",
        appKey: "4f304359baa6d0fd1f9106aaeb116f33",
        debug: true
    } );


    if ( !bc.isCompatible() )
	{
        alert( "your browser is not WebRTC compatible !" );
        return;
    }

    bc.signaling.bind( "onConnected", function ()
	{
		bc.joinRoom ( "conference_demo" );
    } );

    bc.signaling.bind( "onJoinedRoom", function ( data )
	{
		// according to the available bandwidth the resolution could be automatically ajusted between 320x240 and 640x480
        bc.startStream ( {
			audio: true,
			video: {
				height: {
					min: 240,
					max: 480
				},
				width: {
					min: 320,
					max: 640
				}
			 } }, function ( stream )
			 {
				bc.attachStream ( stream, document.body, { mirror: true } );
				
				data.members.forEach ( function (member)
				{
					bc.call( member.id, data.room, { stream: stream, mirror: true } );
				} );
			}
		);
    } );

    bc.streams.bind ( "onStreamAdded", function ( remoteStream )
	{
        bc.attachStream ( remoteStream, document.body );
    } );
    
    bc.streams.bind ( "onStreamClosed", function ( stream ) {
        bc.detachStream ( stream );
    } );

    bc.connect ();
}