【问题标题】:Maximage 2.0 - HTML5 Video random startMaximize 2.0 - HTML5 视频随机启动
【发布时间】:2013-09-05 16:56:20
【问题描述】:
【问题讨论】:
标签:
javascript
jquery
jquery-plugins
html5-video
【解决方案1】:
找到了,你需要获取你的元素,然后调用play()函数:
视频的html:
<video id="vid_1" poster="http://sandbox.thewikies.com/vfe-generator/images/big-buck-bunny_poster.jpg" width="640" height="360">
<source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4" />
<source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.webm" type="video/webm" />
<source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv" type="video/ogg" />
Your browser does not support HTML5 videos.
</video>
然后获取视频元素并触发播放:
//video play button
$('.play_button').click(function(){
var video = $('video#vid_1').get(0); //get the native browser source
if (video.paused) {
video.play(); //if paused, play
}
else{
video.pause(); //if playing, pause
}
});
所以基本上你可以随时调用它...