Change video being played in HTML5 video
I'm using the tags in HTML5 to play a video on a web browser... (and I'm very impressed with this new feature)
Is there the functionality to change the video being played through Javascri开发者_StackOverflow社区pt? Say when I select another video from a list, a Javascript function would be called which would contain something on the lines of MyVideo.VideoLocation = //location of new video to be played
. Is this possible please?
Thanks and regards, Krt_Malta
Webkit requires that you call "load()" after changing the source:
videoTag.src = "newVideo";
videoTag.load();
videoTag.play();
Apple has a useful tutorial.
Here is the solution, tested on Ipad/Iphone/Webkit/Firefox
<script>
function playNext(path,target)
{
target[0].src=path;
target[0].load();
target[0].play();
}
playNext("pathToMovie",$('#video_1'));
</script>
The property to be used:
videoTag.src
If it doesn't auto-start playing after that:
videoTag.play()
精彩评论