For better accessibility we needed a second alternative set of play/pause controls and (with the help of user Kento Nishi) we successfully moved from DEMO A (with only 1 audio playback control) to DEMO B (with duplicated audio playback controls).
PROBLEM1 The time duration (far right number) is broken in DEMO B.
PROBLEM2 Every webpage has its own folder. Some pages have a spoken audio file ready made, *.mp3
but some pages dont. Would it be possible to hide all audio controls html if the spoken.mp3 (same file name for all pages) is absent in the page's own filder? So in summary: if the *.mp3 file exists on the server in the current web page folder <source src="*.mp3" type="audio/mpeg">
then display the html for the audio controls. Otherwise hide the audio html controls via CSS.
The old DEMO A, with only 1 set of controls:
var play = document.getElementsByTagName('play')[0];
var pause = document.getElementsByTagName('pause')[0];
The new DEMO B, with multiple set of controls:
document.getElementsByTagName("playpause")[0].addEventListener("click", playpause);
document.getElementsByTagName("playpause")[1].addEventListener("click", playpause);
Here JS Lint shows errors: unexpected for
and unexpected var
, but I doubt wether these the reason behind the broken audio time duration.
BEAUTY The good part about both demos A & B are that the audio file is loaded not until (and only after) a user clicks play. That way not wasting any bandwith untill user clicks play! This functionality is important and should remain intact, as well as the duplicated set of controls layout-wise and the html parts should remain as much as possible intact.
BOUNTY:200 The new demo works except the duration/audio length is broken and when audio file is not existing the controlls are shown. The bounty is a little token of appreciation for a solution to either problems (or both) in a working jsfiddle demo. Thanks for any and all help.