Playing HTML 5 video from Angular 2 Typescript

Discussão em 'Angular' iniciado por SoundStage, Fevereiro 4, 2025.

  1. SoundStage

    SoundStage Guest

    I want to start playing a HTML video programmatically from TypeScript when the User clicks on the Video area itself.

    This is my HTML code:

    <div class="video">
    <video controls (click)="toggleVideo()" id="videoPlayer">
    <source src="{{videoSource}}" type="video/mp4" />
    Browser not supported
    </video>
    </div>


    This is my TypeScript code:

    @ViewChild('videoPlayer') videoplayer: any;

    toggleVideo(event: any) {
    this.videoplayer.play();
    }


    The issue is that I get an error that says play() function is not defined/exists. What could be the mistake here?

    Continue reading...

Compartilhe esta Página