[Js open source component development] html5 tag audio style change, html5audio

Source: Internet
Author: User

[Js open source component development] html5 tag audio style change, html5audio
Style Change of html5 tag audio

Thanks to the popularity of html5, audio can be used to play audio for most mobile terminals, but you may only need simple playback/Stop effects, however, the audio style on different browsers is not satisfactory, So I simply encapsulate it and the effect is as follows:

As a technical implementation, its principle is relatively simple, that is, to hide the Native audio, then use div to display the player effect, and then call its click event to trigger play and stop, then there is the duration. This value can be obtained sometimes, sometimes it is not good, it is relatively pitfall, so we recommend that you customize the duration of the duration Attribute on the audio tag. At this time, this value will be obtained if the component cannot be obtained.

This.settings.tar get. on ('loadedmetadata', function () {_ this. duration = _ this. audio. duration; if (_ this. duration! = "Infinity") pai_this.durationcontent.html (Math. floor (_ this. duration) +'s ');} else {var attr = getting get ). attr ('duration') + "s" );}else{_this.durationContent.html ('');}}});

Related Article

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.