Wednesday, May 27, 2015

HTML5 Tags - audio

<audio>

  • Provides a standard for playing audio files.
  • Used to add audio to web pages.

            <audio src = "" controls > Audio </audio>

            <audio src = "jb.mp4" controls > Audio </audio>
  • src attribute
    • specifies the url of the audio file
  • controls attribute
    • specifies that audio controls should be displayed (such as a play/pause button etc)
  • autoplay attribute
    • specifies that the audio will start playing as soon as it is ready
  • loop attribute
    • specifies that the audio will start over again, every time it is finished

  • if the browser not supported to the audio file type ,following is the method of specified the audio source files
               <audio controls autoplay loop>
<source src = "jb.mp4" type="audio/mpeg" >
<source src = "jb.ogg" type="audio/ogg">
Audio
</audio>

               

  • <source> element 
    • source elements are in between starting and ending audio tags.
    • does not have a end tag.
    • if the browser does not support for the first audio type then it contry the next one.
    • ogg audio file is the latest version of chrome firefox and opera.
    • Can have the attributes
      • src (address)
        • There are two type of addresses.
          • relative address :- in the above example related to relative address
          • absolute address :- when we used an audio in internet we used absolute address
      • type
        • optional attribute
        • help the browser to specify the audio type


    <video> 

  • Provides a standard for playing video files.
  • Used to add video to web pages.

       In here audio is replaced to video

                <video controls autoplay loop>
<source src = "jb.mp4" type="video/mp4" >
<source src = "jb.mp4" type="video/ogg">
Video
                </video>