0

On a simple page i have a list of titles, clicking on any title will dynamically update the src of a element on the page. This works fine... a few times... then the browser (Safari) refuses to update the src any more, in the debugger it says something about failing to load local resource. If I how ever refresh the page, it will start working again, a few times until it stops again. It seems to work in all other browsers so I'm guessing it's a bug in Safari.

I simply update the src attribute of my video tag, and then call "load()" on the element. I've also tried totally replacing the video element each time instead, but with the same result.

Any hints / workarounds?

Clarification: If I update the src with exactly the same source all the time will still exhibit the buggy behavior using Safari (v6.0.2). Replacing the src works a few times, then the browser suddenly stops accepting updates to the src and emits an error about not being able to load local resource.

HTML part:

<video controls>
    <source type="video/mp4" src="videos/myvideo.mp4"/>
</video>
<button id="#buttonChangeVideo">Change video</button>

Javascript/jQuery part:

$('#buttonChangeVideo').click(function() {
    var $video = $('video');
    $video.attr('src', 'videos/myvideo.mp4');
    $video.get(0).load();
}); 
4

1 回答 1

1
<source type="text/html" src="videos/myvideo.mp4"/>

$video.attr('src', 'video/myvideo.mp4');

视频视频是有区别的

于 2013-02-02T18:32:02.087 回答