mirror of https://github.com/OpenVidu/openvidu.git
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { Component, OnInit, Input, ViewChild } from '@angular/core';
|
|
import { Stream, Session } from 'openvidu-browser';
|
|
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
|
|
|
@Component({
|
|
selector: 'stream',
|
|
styles: [`
|
|
.participant {
|
|
margin: 10px;
|
|
}
|
|
.participant video {
|
|
|
|
}`],
|
|
template: `
|
|
<div class='participant'>
|
|
<p>{{stream.getId()}}</p>
|
|
<video autoplay="true" [src]="videoSrc"></video>
|
|
</div>`
|
|
})
|
|
export class StreamComponent {
|
|
|
|
@Input()
|
|
stream: Stream;
|
|
|
|
videoSrc: SafeUrl;
|
|
|
|
constructor(private sanitizer: DomSanitizer) { }
|
|
|
|
ngOnInit() {
|
|
|
|
let int = setInterval(() => {
|
|
if (this.stream.getWrStream()) {
|
|
this.videoSrc = this.sanitizer.bypassSecurityTrustUrl(
|
|
URL.createObjectURL(this.stream.getWrStream()));
|
|
console.log("Video tag src=" + this.videoSrc);
|
|
clearInterval(int);
|
|
}
|
|
}, 1000);
|
|
|
|
//this.stream.addEventListener('src-added', () => {
|
|
// this.video.src = this.sanitizer.bypassSecurityTrustUrl(URL.createObjectURL(this.stream.getWrStream())).toString();
|
|
//});
|
|
}
|
|
|
|
} |