开发者

Change video being played in HTML5 video

开发者 https://www.devze.com 2022-12-29 10:22 出处:网络
I\'m using thetags in HTML5 to play a video on a web browser... (and I\'m very impressed with this new feature)

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()
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号