[Original] [WebKit mobile Development Notes] audio elements that cannot be automatically played

Source: Internet
Author: User

HTML5 adds video and audio elements, replacing traditional html4. it uses complex object elements and embed to play video or audio. In this project, the product manager asked the mobile phone to play the music at the start of loading. The audio element must be the first choice for playing the music on iOS and Android platforms.

I. Basic knowledge of audio

Audio: tags define sounds, such as music or other audio streams.

Ii. Audio attributes

Iii. Audio writing

Statement 1:

<Audio src = "baishuyun" auto loop> your browser does not support it yet </audio>

Statement 2:

<Audio controls = "controls"> <source src = "baishu.ogg" type = "audio/Ogg"> <source src = "baishuw." type =" audio/MPEG "> priority: baishu.ogg.
</Audio>

Iv. Audio practices

When using audio in the project, we started testing in the Chrome browser and used the AutoPlay and loop attributes to play and loop automatically when the page was opened. It was successfully supported in chrome, after being released to the test environment, music is not automatically played on iOS and Android phones --!, After a series of tests, JavaScript still cannot be played automatically...

I want to use HTML 4 object elements and embed, but some browsers on the mobile phone disable the controls ....

Later, I found some information about the use of audio on a foreign website:

 

The usage of audio is summarized as follows:

1. The autoplay attribute of the audio element cannot be used on iOS and Android, and is normal on the PC end.

2. When the audio element is not set to controls, it occupies space on ISO and Android, while Chrome does not occupy any space on PC.

Later, after discussing with the product manager, I will not use music for the moment... if you have any way to play background music automatically on ISO and Android, please contact me ~~~ Thx

 

References:

Http://stackoverflow.com/questions/4259928/how-can-i-autoplay-media-in-ios-4-2-1-mobile-safari

Http://www.ibm.com/developerworks/library/wa-ioshtml5/index.html

Http://www.w3school.com.cn/html5/html5_audio.asp

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.