Click here to Skip to main content
15,845,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can i create an html5 audio dynamically like this?

XML
var audio = $('<audio>', {
                autoPlay : 'autoplay',
                controls : 'controls',
                src: 'audio/ding.mp3',
                src: 'audio/ding.ogg'
            });


it worked on chrome and firefox but not on ie because i added secound src to audio!
how can i add multiple sources?
Posted
Comments
Sergey Alexandrovich Kryukov 17-Oct-13 14:08pm    
What are you trying to achieve? What is "like this"? Is the audio tag already in your HTML DOM when you execute this part of script, or you create it in the script?
And, by the way, you cannot expect much from IE, it's the least standard browser. What version, by the way? IE10 is said to be better...
—SA
Moosavi S.M. 18-Oct-13 2:20am    
created in script not html, ie 10 and opera 12 doesn't play audio!
i want to define an audio with multiple sources(different audio formats) with jquery dynamically runtime!
Sergey Alexandrovich Kryukov 18-Oct-13 9:51am    
Maybe I don't quite understand your script. I would write longer script, use jQuery Manipulation methods to create inner HTML inside some element... And what do you mean by "second src" (I see the two)? Do you mean that it works with one src on all browsers? If so, write all HTML manually, for the test, and test on IE.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900