<link href="video-js.css" rel="stylesheet" type="text/css"> <script src="video.js"></script> |
<script> videojs.options.flash.swf = "video-js.swf"; </script> |
<video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="640" height="264" data-setup="{}"> <source src="http://视频地址格式1.mp4" type='video/mp4' /> <source src="http://视频地址格式2.webm" type='video/webm' /> <source src="http://视频地址格式3.ogv" type='video/ogg' /> <track kind="captions" src="demo.captions.vtt" srclang="en" label="English"></track> <!-- Tracks need an ending tag thanks to IE9 --> <track kind="subtitles" src="demo.captions.vtt" srclang="en" label="English"></track> <!-- Tracks need an ending tag thanks to IE9 --> </video> |
<script type="text/javascript"> var myPlayer = videojs('example_video_1'); videojs("example_video_1").ready(function(){ var myPlayer = this; myPlayer.play(); }); </script> |
<video id="example_video_1" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" width="640" height="264" poster="[color=rgb(25, 171, 0) !important]http://video-js.zencoder.com/oceans-clip.png" data-setup='{"example_option":true}'> ... </video> |
videojs("example_video_1", {}, function(){ // Player (this) is initialized and ready. }); |
videojs(document.getElementById('example_video_1'), {}, function() { // This is functionally the same as the previous example. }); videojs(document.getElementsByClassName('awesome_video_class')[0], {}, function() { // You can grab an element by class if you'd like, just make sure // if it's an array that you pick one (here we chose the first). }); |
myPlayer.ready(function(){ //在回调函数中,this代表当前播放器, //可以调用方法,也可以绑定事件。 }) |
myPlayer.play(); |
myPlayer.pause(); |
var whereYouAt = myPlayer.currentTime(); |
myPlayer.currentTime(120); |
var howLongIsThis = myPlayer.duration(); |
var whatHasBeenBuffered = myPlayer.buffered(); |
var howMuchIsDownloaded = myPlayer.bufferedPercent(); |
var howLoudIsIt = myPlayer.volume(); |
myPlayer.volume(0.5); |
var howWideIsIt = myPlayer.width(); |
myPlayer.width(640); |
var howTallIsIt = myPlayer.height(); |
myPlayer.height(480); |
myPlayer.size(640,480); |
myPlayer.enterFullScreen(); |
myPlayer.enterFullScreen(); |
durationchange ended //播放结束 firstplay fullscreenchange loadedalldata loadeddata loadedmetadata loadstart pause //暂停 play //播放 progress seeked seeking timeupdate volumechange waiting resize inherited var myFunc = function(){ // Do something when the event is fired }; |
myPlayer.on("ended", function(){ console.log("end", this.currentTime()); }); myPlayer.on("pause", function(){ console.log("pause") }); |
myPlayer.removeEvent(“eventName”, myFunc); |
pd-e1f49eae-2db4-11e4-954d-000c29f61318.zip
99.54 KB, 下载次数: 118
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |