I am trying to create audio tag in html4.
I have
var audioPlayer=document.createElement('audio');
var audioSource=document.createElement('source');
audioSource.src=audioFileName;
audioSource.type="type='audio/mp3'";
audioPlayer.appendChild(audioSource);
audioPlayer.width=320;
audioPlayer.className='text_audio';
audioPlayer.id='audio_id';
audioPlayer.style.margin=0;
audioPlayer.controls='controls';
$('div').append(audioPlayer);
I can see the control bar but it has trouble playing my mp3 file. Are there anyways to do this in Html4?
Thanks a lot!
Correct the
typeproperty – it should just beaudioSource.type = 'audio/mp3';Note that MP3 is not supported by Firefox, so if you’re using that browser that’ll be why it doesn’t work.