<var SESSION_STATUS = Flashphoner.constants.SESSION_STATUS;
var STREAM_STATUS = Flashphoner.constants.STREAM_STATUS;
var session;
 
function init_api() {
    Flashphoner.init({});
    playBtn.onclick = playstream;
}
 
function playstream() {
    var dl8video = document.getElementById('remoteVideo');
    var video = dl8video.contentElement;
    session = Flashphoner.createSession({
        urlServer: "wss://demo.flashphoner.com"
    }).on(SESSION_STATUS.ESTABLISHED, function(session) {
        console.log("connection established"); {
            var options = {
                name: "stream1",
                display: document.getElementById("myVideo"),
                remoteVideo: video,
                transport: "TCP",
            };
            var stream = session.createStream(options).on(STREAM_STATUS.PLAYING, function(stream) {
                console.log("playing");
                dl8video.start();
            });
            stream.play();
        }
    });
}