Reputation: 12619
In chrome (7.0.517.44) I am using the <video>
tag and the audio will only play every other time the video is played.
Why is the audio not always playing along with the video?
In page:
<div id="VideoShow">
<video id="VideoPlay" width=800 height=600></video>
</div>
On click this JS is run.
function playVideo(videoName) {
$("#VideoShow").fadeIn(300);
var Vid = document.getElementsByTagName('video')[0];
Vid.src = videoName;
Vid.play();
Vid.addEventListener('ended', function(e) {
closeVideo();
}, false);
}
function closeVideo() {
var Vid = document.getElementsByTagName('video')[0];
Vid.removeEventListener('ended', arguments.callee, false);
Vid.pause();
$("#VideoShow").fadeOut(300);
}
Upvotes: 2
Views: 350
Reputation: 429
I had a very similar problem with the <audio>
tag recently. Although I wasn't able to determine the actual cause, I was able to work around the issue by removing the old <audio>
element from the DOM and replacing it with an identical element immediately before each call to play().
Upvotes: 1
Reputation: 153
I continue to find inconsistencies with the behavior of these elements.
Have you tried waiting to run the .play() method until after you receive a canplay or canplaythrough event?
Might be worth a shot.
Upvotes: 0