You can get a reference to the video
element by using a local variable and @ViewChild
@Component({
selector: 'my-app',
template : `<video #my-video></video>`
})
export class App implements AfterViewInit {
// myVideo == #my-video
@ViewChild('myVideo') myVideo: any;
afterViewInit() {
let video = this.myVideo.nativeElement;
video.src = URL.createObjectURL(yourBlob);
video.play();
}
Here's a plnkr demonstrating the case (the plnkr differs a little bit, since I couldn't load a video, apparently it's no that simple, instead I load an image as the poster for video tag. You'll get the idea)
Update
You deleted your last comment, but it was a valid question since the docs only specify one way of using @ViewChild
.The docs use the type to query for the children, but you can also use a string. See in ViewChildMetadata#L327
that it accepts a Type (Component/Directive) or a string.
Update 2
Actually the docs show this alternative, but it's in another part of it. Under Query
docs you can see it. Note that Query
is deprecated, but the syntax is still valid for ViewChild/ViewChildren
and ContentChild/ContentChildren
.