I've got a project where I've got several videos that I'd like to dynamically load into the page. my HTML is fairly simple a single video tag
<video controls preload width="520" height="350" id="video">
<source src="videos/video0.mp4" type="video/mp4" id="video_source">
</video>
<div id="playlist">
<a href="videos/video1.mp4">Video File Tomorrow</a>
<a href="videos/video2.mp4">Video File Tomorrow</a>
</div>
I'm only using an MP4 file because this project only needs to function in Safari. I've tried 2 JS solutions and both seem to generate separate issues
Solution 1
$("#playlist a").click(function(){
var video_source_link=$(this).attr("href");
document.getElementById("video_source").setAttribute("src",video_source_link);
document.getElementById("video").load();
document.getElementById("video").play();
return false;
});
In this version JS updates the src attribute of the source tag but does not load the video.
Solution 2
$("#playlist a").click(function(){
var video_source_link=$(this).attr("href");
document.getElementById("video_source").setAttribute("src",video_source_link);
document.getElementById("video_source").load();
document.getElementById("video_source").play();
return false;
});
In this version the video loads into a blank window and when I click the back button Safari crashes with the following error WebKit2WebProcess.exe has encountered a problem and needs to close