muaz-khan / getScreenId

getScreenId | Capture Screen on Any Domain! This script is a hack used to support single chrome extension usage on any HTTPs domain.
https://www.webrtc-experiment.com/getScreenId/
MIT License
63 stars 29 forks source link

Screen Sharing With Audio #1

Closed lyl0921 closed 8 years ago

lyl0921 commented 8 years ago

hi, I want to share the screen with audio. Firefox is ok, but chrome is not. the callback paramter of constraints in chrome is following: screen_constraints { "video": { "mandatory": { "chromeMediaSource": "desktop", "maxWidth": 1280, "maxHeight": 720, "chromeMediaSourceId": "duqJhQS6UlzRqFpgGB4W5w==", "maxFrameRate": 10 }, "optional": [] }, "audio": true } in firefox is following: screen_constraints { "video": { "mozMediaSource": "screen", "mediaSource": "screen", "width": { "max": 1280 }, "height": { "max": 720 }, "frameRate": { "max": 10 } }, "audio": true }

after function getUserMedia(), it will be going to the failed callback, the error message is none as following: NavigatorUserMediaError {name: "ScreenCaptureError", message: "", constraintName: ""}

How can I do if I want to share screen with audio in chrome?

Thanks!

muaz-khan commented 8 years ago

You can capture two parallel streams: one for audio and another one for screen.

Now,

screenStream.addTrack( audioStream.getAudioTracks()[0] );

// this "screenStream" now has audio tracks as well
peer.addStream(screenStream);
peer.createOffer(.....and so on.....);
lyl0921 commented 8 years ago

I capture two parallel streams, than it will be right in chrome. Thank you too much!