Audioplayer.js plug-in use and small bug

Source: Internet
Author: User

Before in the project with Audioplayer.js to do a page, changed the layout style, and the plugin itself has a bug is the audio Add AutoPlay property After there are two video playback, one of which can not control, will always play, I check the official website of the demo is also the case, checked a half-day finally found out

The problem is on the top of clone ():

<audio Controls Autoplay>
<source src= "Music/333.mp3" >
</audio>
Change the part of the source code that generates the DOM after the audio tag clone to create a parent element on the original tag and insert it into the DOM
var Theplayer = $ (' <div class= "' + Params.classprefix + '" ></div> ');
$ ('. Detail_content '). Append (Theplayer);
$this. AppendTo (Theplayer);
$ (' <div class= "' + Cssclass.playpause + '" title= "' + Params.strplay + '" ><a href= "#" > ' + Params.strplay + ' & Lt;/a></div> '). AppendTo (Theplayer);
And then add an autoplay command

if (isautoplay) {theplayer.addclass (cssclass.playing); Theaudio.play ();}
Since I am not involved in too much compatibility, the code that determines whether the ternary operator supports the audio tag is not added,
And finally added a point before the progress was played.

$ (". audioplayer-bar-played"). Append ("<span class= ' Append_drop ' ></span>");




That's probably it.
Below is HTML5 's audio, video tag's JS event and Tag Properties

Event name Description
abort Triggered when playback is terminated, for example, when a video in playback starts playing again.
canplay Triggered when the media data already has enough data (at least to play a few frames) to play. This event corresponds to Can_play's readystate.
canplaythrough Triggered when the media's readystate becomes can_play_through, indicating that the media can play without interruption while maintaining the current download speed. Note: Setting currenttime manually causes Firefox to trigger a Canplaythrough event, which may not be the case for other browsers.
durationchange Meta-information has been loaded or changed, indicating that the length of the media has changed. For example, this event is triggered when the media has been loaded sufficiently long to know the total length.
emptied Triggered when the media is emptied (initialized).
ended Triggered at the end of playback.
error Triggered when an error occurs.
loadeddata The first frame of the media has been loaded.
loadedmetadata The metadata for the media has been loaded, and all properties now contain valid information that they should have.
loadstart Triggered when the media starts to load.
mozaudioavailable When the audio data is cached and handed over to the audio layer processing
pause Triggered when playback is paused.
play triggered when the media playback is paused and starts again. That is, resume media playback after a pause event.
playing Triggered when the media starts playing (whether it's a first play, resuming after a pause, or restarting after the end).
progress Periodically triggers when the download progress is communicated to the relevant part of the media. Information about the total that the media is currently downloading can be obtained in the buffered attribute of the element.
ratechange triggered when the playback rate changes.
seeked Triggered when the jump operation is complete.
seeking Triggered at the start of a jump operation.
stalled Triggered when an attempt is taken to obtain media data, but the data is not available.
suspend triggered when the media resource load terminates, possibly because the download has completed or is paused for other reasons.
timeupdate The time that the currenttime attribute of the element represents has changed.
volumechange triggered when the audio volume changes (either the volume property changes or the muted property change) ...
waiting Triggered when a pending operation, such as playback, is delayed by waiting for another operation, such as a jump or download.
   


properties

Strong id= "Attr-autoplay" > AutoPlay Boolean property, if specified (the default value is "false"!) When specified, the audio will automatically start playing immediately, and will not stop waiting for data loading to finish.
buffered You can get the time period information for a buffered resource by this property. This property contains a Timerenges object.
controls If this property is set, the browser will provide a control panel that contains sound, playback progress, playback pauses, and allows the user to control the playback of the audio.
Loop Boolean property, and if specified, the audio will be looped back.
mozcurrentsampleoffset   When audio is playing, Represents a numeric value relative to the offset at the beginning of the audio.
muted indicates whether to mute the Boolean value. The default value is False, which indicates a sound.
played one
Timerenges object that represents all the audio clips that have been played. The
preload Enumeration property lets developers think about how the browser uses the loading method to achieve the best user experience. Can be one of the following properties:
    • none: Signals that the user may not play the audio, or the server wants to conserve bandwidth; in other words, the audio is not cached;
    • metadata: Signals that it is necessary to get metadata (such as audio length) even if the user may not play the audio.
    • auto: Signals that the user may play audio, in other words, if necessary, the entire audio will be loaded, even if the user does not expect to use it.
    • Empty string: Equivalent to an auto attribute.

If not set, the default value is the browser definition (different browsers will choose their own default values), even if the specification is set to metadata .

Use notes:
  • autoplayAttribute takes precedence over preload if the user wants to play the video automatically, it is obvious that the browser needs to download the video. Both settings autoplay and preload attributes are allowed in the specification.
  • The specification does not force the browser to follow the value of the property; it's just a hint.
src
The URL of the embedded audio. You can use the <source> element in the audio element to override this property to specify embedded audio.
volume
the volume of the audio playback. Values from 0.0 (silent) to 1.0 (maximum sound).

The time offset is currently the value specified as float, which represents the number of seconds to offset.

remark: The definition of the time offset value in the HTML 5 specification has not been completed and is subject to change.
buffered: get the first buffer range (part) of the video in seconds:
myVid.buffered. Start (0) + "End:" + myVid.buffered.end (0));


Audioplayer.js plug-in use and small bug

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.