<audio> Tag Properties:
- src: The URL of the music
- Preload: Pre-load
- AutoPlay: Auto Play
- Loop: Looping Playback
- Controls: Browser's own control
<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
Get Htmlvideoelement and Htmlaudioelement objects
1 // audio can create objects directly from new 2 New Audio ("Http://www.abc.com/test.mp3"); 3 // both audio and video can be used to get objects from tags 4 Media = document.getElementById ("media");
Media methods and properties: Both Htmlvideoelement and htmlaudioelement inherit from Htmlmediaelement
1 //Error Status2Media.error;//null: Normal3Media.error.code;//1. User termination 2. Network error 3. Decoding Error 4.URL Invalid4 5 //Network Status6MEDIA.CURRENTSRC;//returns the URL of the current resource7MEDIA.SRC = value;//Returns or sets the URL of the current resource8Media.canplaytype (type);//Whether you can play a resource in a certain format9Media.networkstate;//0. This element is not initialized 1. Normal but not using network 2. Downloading Data 3. No Resources foundTenMedia.load ();//reload the resource specified by SRC Onemedia.buffered;//returns the buffered area, Timeranges AMedia.preload;//None: Do not preload metadata: Preload resource information auto: - - //Readiness Status theMedia.readystate;//1:have_nothing 2:have_metadata 3.have_current_data 4.have_future_data 5.have_enough_data -media.seeking;//Are you seeking - - //Playback Status +Media.currenttime = value;//current playback position, assignment can change position -Media.starttime;//typically 0, not 0 if it is a streaming medium or a resource that does not start at 0 +Media.duration;//Current resource length stream returns unlimited Amedia.paused;//whether to pause atMedia.defaultplaybackrate = value;//The default playback speed, you can set -Media.playbackrate = value;//Current playback speed, change immediately after setting -media.played;//returns the area that has been played, timeranges, for this object see below -media.seekable;//returns the area that can be seek timeranges -media.ended;//whether to end -Media.autoplay;//whether to play automatically inMedia.loop;//whether to loop playback -Media.play ();//Play toMedia.pause ();//Pause + - //Control theMedia.controls;//whether there is a default control bar *Media.volume = value;//Volume $media.muted = value;//MutePanax Notoginseng - //timeranges (Region) object theTimeranges.length;//number of Region segments +Timeranges.start (Index)//start position of the area of the Index section ATimeranges.end (Index)//end position of the area of the Index section
Event:
1Eventtester =function(e) {2Media.addeventlistener (E,function(){3Console.log ((NewDate ()). GetTime (), e);4 });5 }6 7Eventtester ("Loadstart");//The client begins to request data8Eventtester ("Progress");//client is requesting data9Eventtester ("suspend");//Delayed DownloadTenEventtester ("Abort");//the client actively terminates the download (not due to an error), OneEventtester ("error");//error encountered while requesting data AEventtester ("stalled");//Speed Stall -Eventtester ("Play");//triggers when play () and AutoPlay start playing -Eventtester ("pause");//pause () trigger theEventtester ("Loadedmetadata");//successful acquisition of resource length -Eventtester ("Loadeddata");// -Eventtester ("Waiting");//wait for data, not error -Eventtester ("playing");//Start Playback +Eventtester ("Canplay");//can be played, but may be paused halfway through loading -Eventtester ("Canplaythrough");//can play, the songs are all loaded +Eventtester ("seeking");//Find in AEventtester ("seeked");//Search Complete atEventtester ("Timeupdate");//Play time Change -Eventtester ("ended");//Play End -Eventtester ("Ratechange");//Playback Rate Change -Eventtester ("Durationchange");//Resource Length Change -Eventtester ("Volumechange");//Volume Change
Audio and video properties and event summaries in HTML5