simplewebrtc / SimpleWebRTC

Simplest WebRTC ever

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Screen Share doesn't work with https ngrok or localhost

hipkiss91 opened this issue · comments

Does this actually work?
The code works on a "chrome tab" website and the desired outcome of chrome asking me which screen to select happens. But when doing it from a new window/popup window launched from the chrome tab website then it doesn't have the desired outcome. Anyone any thoughts?

All the console logs get triggered. Just no prompt to select screen (same screen selection thing as chromecast)

// 1. insert webrtc-adapter script 
    let webrtcAdapterScript = document.createElement('script'); 
    webrtcAdapterScript.type = 'text/javascript'; 
    webrtcAdapterScript.src = 'https://example.com/webrtcAdapter.js'; 
    document.body.appendChild(webrtcAdapterScript); 
 
    // 2. insert getscreenmedia script 
    let screenMediaScript = document.createElement('script'); 
    screenMediaScript.type = 'text/javascript'; 
    screenMediaScript.src = 'https://example.com/getScreenMedia.js'; 
    document.body.appendChild(screenMediaScript);

import SimpleWebRTC from 'SimpleWebRTC';

    setTimeout(()=>{
		desktopShare = new window.SimpleWebRTC({
			localVideoEl: 'local-desktop-el',
			remoteVideosEl: '',

			autoRequestMedia: false,
			url: 'https://example.com',
			debug: false,
			detectSpeakingEvents: false,
			autoAdjustMic: false,

			media: {
				video: false,
				audio: false,
			},
			receiveMedia: {
				offerToReceiveVideo: true,
				offerToReceiveAudio: false,
			},
		});
		desktopShare.on('readyToCall', () => {
			console.log('READYTOCALL triggered'); 
			desktopShare.joinRoom('desktopShare');
			desktopShare.shareScreen(()=>{
				console.log('Desktop Shared');
			});
		});
    },10000);

Here is the part of the manifest file, of the extension:

  "content_scripts": [{
    "js": ["content.js"],
    "matches": [
      "https://*.ngrok.io/*"
    ]
  }],
  "externally_connectable": {
    "matches": [
      "https://*.ngrok.io/*"
    ]
  },