You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realize that this may be an uncommon use, but I'm using a single <audio> element to play multiple tracks. That is, the element starts out with no source (just <audio autoplay></audio>) and, based on the user's interaction, loads a specific file and begins playing it.
html5media appears to assume that the element has at least one source. This document, for instance, raises an error in the latest versions of Safari and Firefox for me:
Thanks for the report. There's certainly a way to accomplish what you're trying to do. Rather than attaching the source elements to the audio tag dynamically, try using a container element that you add complete audio elements too dynamically. Whenever you add an audio tag, call html5media() to kick in the fallback for unsupporting browsers.
Does your code work correctly in all html5-compliant browsers without including the html5media code? The reason I ask, is that I'm a bit unclear on whether an audio tag with no specified source is actually valid HTML. If it is, and your code works without error without html5media, then I'll add in this feature. If an audio tag with no source isn't valid HTML, then I'll adjust it to give a more informative error message.
The trunk version of the script handles loading audio source identically. Are you sure that you're using the complete, compiled version of the script when linking to the trunk?
You're absolutely right that it's not clear from the standard whether omitting the source is valid. In my experience, it seems to work in Safari, Firefox, and Chrome, but the documentation is sparse enough that it's difficult to tell whether this is intentional.
Dynamically adding/replacing the audio element does seem like the way to go in the meantime. Thanks for the idea.
I'm really not sure whether to make this throw an error, or just ignore media tags with no source. In the latter case, you'd still need to call html5media() to kick in the fallback player when the source has been dynamically inserted.
I've updated the code to fail silently if no source element could be found. This allows the code to run without errors, since this markup is probably valid.
Once source elements have been supplied, the programmer can then call html5media() to kick in the fallback;
I realize that this may be an uncommon use, but I'm using a single
<audio>
element to play multiple tracks. That is, the element starts out with no source (just<audio autoplay></audio>
) and, based on the user's interaction, loads a specific file and begins playing it.html5media appears to assume that the element has at least one source. This document, for instance, raises an error in the latest versions of Safari and Firefox for me:
The error as reported by Safari is:
Oddly, I can only seem to recreate this in the minified version of the script -- maybe this is fixed in the latest source?
The text was updated successfully, but these errors were encountered: