I want to create an app to capture one window as a video source, so far I am using desktopCapturer get the sources info and using getUserMedia to put it in a . but the video is like a still picture not show any changes on the window, just a mouse moving around. Could any one help me with this problem. thank you so much.
here is my code:
getAllScreenInfo: () => {
let st = new Date();
return new Promise((resolve, reject) => {
desktopCapturer.getSources({types: [‘window’, ‘screen’]}, (error, sources) => {
console.info('screen source get end at ', (new Date() - st) / 1000);
if (error) {
reject(error);
} else {
resolve(sources);
}
})
})
},
getScreen: (id, obj, rf) => {
return new Promise((resolve, reject) => {
let w = 1920;
let h = 1080;
navigator.webkitGetUserMedia({
audio: false,
video: {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: id,
minWidth: w,
maxWidth: w,
minHeight: h,
maxHeight: h
}
}
}, (stream) => {
obj.src = URL.createObjectURL(stream);
resolve();
}, (e) => {
reject(e);
});
});
},
VideoSources.getAllScreenInfo().then(sources => {
console.info(‘all sources’, sources);
sources = sources.filter(source => {
return (source.name === ‘Screen 1’ || source.name.indexOf(‘Word’) >= 0);
})
this.setState({sources: sources});
});