function shareStreamUsingAntMediaServer(stream) { var wrapper = new AntMediaWrapper(); wrapper.callbacks('onopen', function() { var uid = room_id || (Math.random() * 100).toString().replace('.', ''); wrapper.publish(stream, uid, function(isPublished, error) { if (isPublished === true) { var resultingURL = 'http://webrtcweb.com/screen/ant/?s=' + uid; var hlsURL = 'http://webrtcweb.com/screen/ant/?s=' + uid + '&hls=true'; var html = "Unique Room URL

Copy following private URL:

"; html += "


"; html += "


"; var popup_width = 600; var popup_height = 230; chrome.windows.create({ url: "data:text/html," + html, type: 'popup', width: popup_width, height: popup_height, top: parseInt((screen.height / 2) - (popup_height / 2)), left: parseInt((screen.width / 2) - (popup_width / 2)), focused: true }, function(win) { popup_id = win.id; }); chrome.browserAction.enable(); setBadgeText(0); } else { alert(error); } }); }); wrapper.callbacks('onerror', function() { alert('Ant-Media Server is down or not reachable in the moment. Please go to options page and try other streaming method.'); stream.getTracks().forEach(function(track) { track.stop(); }); setDefaults(); }); }