"Reprint" HTML5 Audio/video tags, properties, methods, Event summary

Source: Internet
Author: User

<audio> Tag Properties:
    • src: The URL of the music
    • Preload: Pre-load
    • AutoPlay: Auto Play
    • Loop: Looping Playback
    • Controls: Browser's own control bar
HTML code
    1. <audio id= "Media" src= "http://www.abc.com/test.mp3″controls></audio>

<video> Tag Properties:
    • SRC: URL of the video
    • Poster: Video cover, no picture displayed when playing
    • Preload: Pre-load
    • AutoPlay: Auto Play
    • Loop: Looping Playback
    • Controls: Browser's own control bar
    • Width: Video width
    • Height: Video Height
HTML code
    1. <video id= "Media" src= "Http://www.abc.com/test.mp4″controls width=" 400px "heigt=" 400px "></video>

Get Htmlvideoelement and Htmlaudioelement objects

JS Code
    1. Audio can create objects directly from new
    2. Media = new Audio ("Http://www.abc.com/test.mp3″");
    3. Both audio and video can be used to get objects from tags
    4. Media = document.getelementbyidx_x ("media");

Media Methods and properties:

Both Htmlvideoelement and htmlaudioelement inherit from Htmlmediaelement

JS Code
  1. Error status
  2. Media.error; Null: Normal
  3. Media.error.code; 1. User Termination 2. Network error 3. Decoding Error 4.URL invalid
  4. Network status
  5. MEDIA.CURRENTSRC; Returns the URL of the current resource
  6. MEDIA.SRC = value; Returns or sets the URL of the current resource
  7. Media.canplaytype (type); Whether you can play a resource in a certain format
  8. Media.networkstate; 0. This element is not initialized 1. Normal but not using network 2. Downloading Data 3. No Resources found
  9. Media.load (); Reload the resource specified by SRC
  10. media.buffered; Returns the buffered area, timeranges
  11. Media.preload; None: Do not preload metadata: Preload resource information Auto:
  12. Readiness Status
  13. Media.readystate; 1:have_nothing 2:have_metadata 3.have_current_data 4.have_future_data 5.have_enough_data
  14. media.seeking; Are you seeking
  15. Playback status
  16. Media.currenttime = value; Current playback position, assignment can change position
  17. Media.starttime; Typically 0, not 0 if it is a streaming medium or a resource that does not start at 0
  18. Media.duration; Current resource length stream returns unlimited
  19. media.paused; Whether to pause
  20. Media.defaultplaybackrate = value;//The default playback speed, you can set
  21. Media.playbackrate = value;//Current playback speed, change immediately after setting
  22. media.played; Returns the area that has been played, timeranges, for this object see below
  23. media.seekable; Returns the area that can be seek timeranges
  24. media.ended; Whether to end
  25. Media.autoplay; Whether to play automatically
  26. Media.loop; Whether to loop playback
  27. Media.play (); Play
  28. Media.pause (); Time out
  29. Control
  30. media.controls;//whether there is a default control bar
  31. Media.volume = value; Volume
  32. media.muted = value; Mute
  33. Timeranges (Region) object
  34. Timeranges.length; Number of Region segments
  35. Timeranges.start (index)//start position of the area of the index section
  36. Timeranges.end (index)//End position of the section of the index area

Event:

JS Code
  1. Eventtester = function (e) {
  2. Media.addeventlistener (E,function () {
  3. Console.log (New Date ()). GetTime (), E);
  4. });
  5. }
  6. Eventtester ("Loadstart"); The client begins to request data
  7. Eventtester ("Progress"); Client is requesting data
  8. Eventtester ("suspend"); Delayed download
  9. Eventtester ("Abort"); The client actively terminates the download (not due to an error),
  10. Eventtester ("error"); Error encountered while requesting data
  11. Eventtester ("stalled"); Speed stall
  12. Eventtester ("Play"); Triggers when play () and AutoPlay start playing
  13. Eventtester ("pause"); Pause () Trigger
  14. Eventtester ("Loadedmetadata"); Successful acquisition of resource length
  15. Eventtester ("Loadeddata"); //
  16. Eventtester ("Waiting"); Wait for data, not error
  17. Eventtester ("playing"); Start playback
  18. Eventtester ("Canplay"); Can be played, but may be paused halfway through loading
  19. Eventtester ("Canplaythrough"); Can play, the songs are all loaded
  20. Eventtester ("seeking"); Find in
  21. Eventtester ("seeked"); Search Complete
  22. Eventtester ("Timeupdate"); Play Time change
  23. Eventtester ("ended"); Play End
  24. Eventtester ("Ratechange"); Playback rate Change
  25. Eventtester ("Durationchange"); Resource length Change
  26. Eventtester ("Volumechange"); Volume change

[Transfer from: http://directguo.com/blog/index.php/2010/07/html5-audio-video-tag/]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.