To use both video and audio in a playlist you should use the html5 video tag instead of the audio tag. You do not need to switch back and forth. The video tag will play both audio and video files.
In order to use the code from the site listed, you will need to know whether you are loading a video or an audio file. Then you can determine the correct extension to use based on browser support found in the script. See the new html5 video and audio playlist example below:
http://jonhall.info/examples/html5_video_audio_playlist_example.html
In the new example I replaced the code:
extension = audio.canPlayType('audio/mpeg') ? '.mp3' : audio.canPlayType('audio/ogg') ? '.ogg' : '';
with a function:
getExtension = function(type) {
extension = '';
if(type === 'a') {
if(video.canPlayType('audio/mpeg')) {
extension = '.mp3';
}
if(video.canPlayType('audio/ogg')) {
extension = '.ogg';
}
}
if(type === 'v') {
if(video.canPlayType('video/mp4')) {
extension = '.mp4';
}
if(video.canPlayType('video/ogg')) {
extension = '.ogv';
}
}
return extension;
};
Pass the letter 'a'
for audio or the letter 'v'
for video.