mirror of https://github.com/OpenVidu/openvidu.git
openvidu-testapp: initGrayVideo refactoring
parent
df4db147f5
commit
57b55bba85
|
@ -503,11 +503,13 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
initGrayVideo(): void {
|
initGrayVideo(): void {
|
||||||
|
|
||||||
this.OV.getUserMedia(
|
this.OV.getUserMedia(
|
||||||
{
|
{
|
||||||
|
audioSource: undefined,
|
||||||
videoSource: undefined,
|
videoSource: undefined,
|
||||||
resolution: '1280x720',
|
resolution: '1280x720',
|
||||||
frameRate: 30,
|
frameRate: 3,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((mediaStream: MediaStream) => {
|
.then((mediaStream: MediaStream) => {
|
||||||
|
@ -530,18 +532,17 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
loop();
|
loop();
|
||||||
});
|
});
|
||||||
const grayVideoTrack: MediaStreamTrack = (<MediaStream>canvas.captureStream(30)).getVideoTracks()[0];
|
const grayVideoTrack: MediaStreamTrack = (<MediaStream>canvas.captureStream(30)).getVideoTracks()[0];
|
||||||
this.publisher = this.OV.initPublisher(
|
this.OV.getUserMedia({
|
||||||
document.body,
|
|
||||||
{
|
|
||||||
audioSource: false,
|
audioSource: false,
|
||||||
videoSource: grayVideoTrack,
|
videoSource: grayVideoTrack
|
||||||
insertMode: VideoInsertMode.APPEND
|
}).then(mediastream => {
|
||||||
});
|
this.publisher.replaceTrack(mediastream.getVideoTracks()[0])
|
||||||
this.session.publish(this.publisher).catch((error: OpenViduError) => {
|
.then(() => console.log('New track is being published'))
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error replacing track');
|
||||||
console.error(error);
|
console.error(error);
|
||||||
this.session.unpublish(this.publisher);
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
Loading…
Reference in New Issue