Example

Audio Video in HTML

HTML

<!DOCTYPE html>
<html lang="en-us">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
        <title>Audio Video in HTML</title>
    </head>
    <body>
<!--
    <video> : element embeds a media player to supports video playback into the document.
    <audio> : element is used to embed sound content in documents.
    <source> : element within the audio/video block to specify the audio/video to be embed.
    src : attribute, include a path to the media we want to display.
    autoplay : boolean attribute; if specified, the audio/video automatically begins to play. 
    controls : attribute will offer controls to allow the user to control audio/video.    
    loop : attribute will automatically seek back audio/video to start upon reaching end.
    muted : attribute, if set, the audio/video will be initially silenced.
    poster : attribute will add image to be shown, while video is downloading.    
-->

    <h1>Demo: Audio Video in HTML</h1>
    
    <div>
        <h2>Video file </h2>
        <video controls 
                width="300" 
                autoplay 
                loop 
                muted 
                poster="/notes/examples/assets/img/skillzam.png">

            <source src="/notes/examples/assets/videos/skillzam.mp4" type="video/mp4" />
            <p>Sorry, your browser doesn't support embedded videos.</p>
        </video>
    </div>

    <hr>

    <div>
        <h2>Audio file </h2>
        <audio controls 
                loop 
                muted>

            <source src="/notes/examples/assets/audio/skillzam.mp3" type="audio/mpeg" />
            <p>Your browser does not support the audio element</p>
        </audio>
    </div>

    </body>
</html>
                     

Output

View original