Merge branch 'feat-getdisplaymedia' into develop
commit
eb81be0ac1
|
|
@ -134,7 +134,7 @@ export default class RoomClient
|
||||||
device : null
|
device : null
|
||||||
};
|
};
|
||||||
|
|
||||||
this._screenSharing = ScreenShare.create();
|
this._screenSharing = ScreenShare.create(device);
|
||||||
|
|
||||||
this._screenSharingProducer = null;
|
this._screenSharingProducer = null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import { getBrowserType } from './utils';
|
|
||||||
|
|
||||||
class ChromeScreenShare
|
class ChromeScreenShare
|
||||||
{
|
{
|
||||||
constructor()
|
constructor()
|
||||||
|
|
@ -109,6 +107,57 @@ class ChromeScreenShare
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Chrome72ScreenShare
|
||||||
|
{
|
||||||
|
constructor()
|
||||||
|
{
|
||||||
|
this._stream = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
start(options = {})
|
||||||
|
{
|
||||||
|
const constraints = this._toConstraints(options);
|
||||||
|
|
||||||
|
return navigator.mediaDevices.getDisplayMedia(constraints)
|
||||||
|
.then((stream) =>
|
||||||
|
{
|
||||||
|
this._stream = stream;
|
||||||
|
|
||||||
|
return Promise.resolve(stream);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
stop()
|
||||||
|
{
|
||||||
|
if (this._stream instanceof MediaStream === false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._stream.getTracks().forEach((track) => track.stop());
|
||||||
|
this._stream = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
isScreenShareAvailable()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
needExtension()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_toConstraints()
|
||||||
|
{
|
||||||
|
const constraints = {
|
||||||
|
video : true
|
||||||
|
};
|
||||||
|
|
||||||
|
return constraints;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class FirefoxScreenShare
|
class FirefoxScreenShare
|
||||||
{
|
{
|
||||||
constructor()
|
constructor()
|
||||||
|
|
@ -255,9 +304,9 @@ class DefaultScreenShare
|
||||||
|
|
||||||
export default class ScreenShare
|
export default class ScreenShare
|
||||||
{
|
{
|
||||||
static create()
|
static create(device)
|
||||||
{
|
{
|
||||||
switch (getBrowserType())
|
switch (device.flag)
|
||||||
{
|
{
|
||||||
case 'firefox':
|
case 'firefox':
|
||||||
{
|
{
|
||||||
|
|
@ -265,9 +314,12 @@ export default class ScreenShare
|
||||||
}
|
}
|
||||||
case 'chrome':
|
case 'chrome':
|
||||||
{
|
{
|
||||||
return new ChromeScreenShare();
|
if (device.version < 72.0)
|
||||||
|
return new ChromeScreenShare();
|
||||||
|
else
|
||||||
|
return new Chrome72ScreenShare();
|
||||||
}
|
}
|
||||||
case 'edge':
|
case 'msedge':
|
||||||
{
|
{
|
||||||
return new EdgeScreenShare();
|
return new EdgeScreenShare();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,31 +19,6 @@ export function isMobile()
|
||||||
return !mediaQueryDetectorElem.offsetParent;
|
return !mediaQueryDetectorElem.offsetParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBrowserType()
|
|
||||||
{
|
|
||||||
const ua = navigator.userAgent.toLowerCase();
|
|
||||||
|
|
||||||
// Firefox
|
|
||||||
if (ua.indexOf('firefox') !== -1)
|
|
||||||
{
|
|
||||||
return 'firefox';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Chrome
|
|
||||||
if (ua.indexOf('chrome') !== -1 && ua.indexOf('edge') === -1)
|
|
||||||
{
|
|
||||||
return 'chrome';
|
|
||||||
}
|
|
||||||
|
|
||||||
// MSEdge
|
|
||||||
if (ua.indexOf('edge') !== -1)
|
|
||||||
{
|
|
||||||
return 'edge';
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'N/A';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a function which will call the callback function
|
* Create a function which will call the callback function
|
||||||
* after the given amount of milliseconds has passed since
|
* after the given amount of milliseconds has passed since
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue