openvidu-testapp: 'initGrayVideo' method publishes video

pull/117/merge
pabloFuente 2018-08-31 16:34:04 +02:00
parent c9289d75a2
commit b2ec6a00e7
1 changed files with 7 additions and 3 deletions

View File

@ -473,7 +473,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
{
videoSource: undefined,
resolution: '1280x720',
frameRate: 10,
frameRate: 30,
}
)
.then((mediaStream: MediaStream) => {
@ -489,19 +489,23 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
const loop = () => {
if (!video.paused && !video.ended) {
ctx.drawImage(video, 0, 0, 300, 170);
setTimeout(loop, 100); // Drawing at 10fps
setTimeout(loop, 33); // Drawing at 30fps
}
};
loop();
});
const grayVideoTrack = canvas.captureStream(30).getVideoTracks()[0];
this.OV.initPublisher(
this.publisher = this.OV.initPublisher(
document.body,
{
audioSource: false,
videoSource: grayVideoTrack,
insertMode: VideoInsertMode.APPEND
});
this.session.publish(this.publisher).catch((error: OpenViduError) => {
console.error(error);
this.session.unpublish(this.publisher);
});
})
.catch(error => {
console.error(error);