Audio problems with HTML pages

Source: Internet
Author: User

FUSE: Responsible for the project in the words of the inter-service module, processing audio a bit of a problem

Previous processing:

  // Loop Play sound

varDialaudiodocument = document.createelement (' Audio '); This is the sound of dialing (only one audio is written here)varDialsource = document.createelement (' source '); Dialsource.type= "Audio/mpeg";d Ialsource.type= "Audio/mpeg";d Ialsource.autoplay= "AutoPlay";d Ialsource.controls= "Controls";

URL: Indicates the audio path, flag: An identity, call or dial out, audio: Indicates the above dialaudiodocument, source: Above the Dialsourcefunctionplayaudio (URL, flag, audio, source) {console.log (URL); Note: This audio is to be played with the source, and there is no way to stop him (for unknown reason) console.log (flag); Console.log (audio); Console.log (source); SOURCE.SRC=URL; Audio.appendchild (source); Audio.play (); if(flag = = "Dial") {Dialalert= SetTimeout ("playaudio" + URL + "', ' dial ', '" +audio+ "', '" +source+ "')", 1000*5); } if(Flag = = "Call") {Callalert= SetTimeout ("playaudio" + URL + "', ' call ', '" +audio+ "', '" +source+ "')", 1000*29); }}
Disadvantage: Because there is no way to let the audio stop, this time can only select the short duration of the audio loop playback, the stop is through Clearinter. The way to stop, and the back of the audio, it is not .....

Little demo at the time: (testing whether this audio method works)

<! DOCTYPE html>

  

  

The current programme:

  

<!--Here's the recording--
<audio id= "Dialaudio" src= "/static/audio/dialaudio.mp3" ></audio>
<audio id= "Callaudio" src= "/static/audio/callaudio.mp3" ></audio>
<audio id= "Hangaudio" src= "/static/audio/hangaudio.mp3" ></audio>

$ (function () {
Initialize the recording label
Dialaudiodocument = document.getElementById (' Dialaudio '); Only document can be obtained here, the reason is unknown, conjecture may be the loading order problem
Callaudiodocument = document.getElementById (' Callaudio ');
Hangaudiodocument = document.getElementById (' Hangaudio ');


Loop play sound function playaudio (document, flag) { Console.log (document); = 0; Document.play (); if (flag = = "Dial") {= SetTimeout ("Playaudio ('" + Document + "', ' dial ')", 1000*5); } if (Flag = = "Call") {= SetTimeout ("Playaudio ('" + Document + "', ' call ')", 1000*29); }}

Stop the sound.
function Pauseaudio (document, flag) {
if (flag = = "Dial") {
Document.pause ();
}
if (flag = = "Call") {
Document.pause ();
}
}

Advantages: Solve the above shortcomings

Take time to record, far greater than dead knocks

  

Audio problems with HTML pages

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.