《jwplayer使用文档.docx》由会员分享,可在线阅读,更多相关《jwplayer使用文档.docx(11页珍藏版)》请在三一文库上搜索。
1、1.jwplayer 播放器初始化var thePlayer;/ 保存当前播放器以便操作$(function() thePlayer = jwplayer(container).setup(flashplayer: jwplayer/player.swf,/jwplayer 播放器file: ,/ 要播放视频的地址width: 1024,/ 播放器宽度height: 512, /播放器高度autostart:true,/ 是否一打开页面就开始播放provider: http,start:,从第几秒开始播放视频dock: false,events: / 定义播放监听事件/onComplete:
2、function () alert( 播放结束 !); ,/ onVolume: function () alert( 声音大小改变!); ,/ onReady: function () alert( 准备就绪 !); ,/onPlay: function () alert( 开始播放 !);,/ onPause: function () alert( 暂停 !); ,onBufferChange: function () / 播放器缓存变化,/ onBufferFull: function () alert( 视频缓冲完成!+thePlayer.getPosition(); ,onError
3、: function (obj) / 播放器出错,/onMeta: function (obj) alert(obj);,/onBeforePlay:function (obj) alert(onBeforePlay);,/onTime:function (obj)alert(onTime:+thePlayer.getPosition()+0.01);,onSeek:function (obj) /拖动播放器 进度条,/onFullscreen: function (obj) if (obj.fullscreen) alert(全屏) else alert(非 全屏 ); ,/onMute:
4、function (obj) console.log( 静音 /取消静音 ) ,/onIdle: function () console.log( 空闲 ) /controls:false/skin:skin/facebook.zip / 设置播放器的皮肤);/ 播放暂停$(.player-play).click(function() if (thePlayer.getState() != PLAYING) thePlayer.play(true);this.value = 暂停; else thePlayer.play(false);this.value = 播放;);/ 停止$(.play
5、er-stop).click(function() thePlayer.stop(); );/ 获取状态$(.player-status).click(function() var state = thePlayer.getState();var msg;switch (state) case BUFFERING:msg = 加载中;break;case PLAYING:msg = 正在播放;break;case PAUSED:msg = 暂停;break;case IDLE:msg = 停止;break;alert(msg););/ 获取播放进度$(.player-current).clic
6、k(function() alert(thePlayer.getPosition(); );/ 跳转到指定位置播放$(.player-goto).click(function() if (thePlayer.getState() != PLAYING) /若当前未播放,先启动播放器/ thePlayer.play();thePlayer.seek(600); /从指定位置开始播放(单位:秒);/ 获取视频长度$(.player-length).click(function() alert(thePlayer.getDuration(); ););2.示例代码%base href=jwplaye
7、r!-basePath=request.getScheme()+:/+request.getServerName ()+:+request.getServerPort()+path+/;pagelanguage=javaimport=java.util.*,dre am.SecurityArithmeticpageEncoding=UTF-8%var thePlayer;/ 保存当前播放器以便操作$(function() thePlayer = jwplayer(container).setup(flashplayer: jwplayer/player.swf,file: ,width: 10
8、24,height: 512,autostart:true,provider: http,start:,dock: false,events: /onComplete: function () alert( 播放结束 !); ,/ onVolume: function () alert( 声音大小改变!); ,/ onReady: function () alert( 准备就绪 !); ,/onPlay: function () alert( 开始播放 !);,/ onPause: function () alert( 暂停 !); ,onBufferChange: function () i
9、f(thePlayer.getPosition()10.00 & thePlayer.getPosition()10.20)window.location.href=http:/192.168.1.13:8080/jwplayer/exam.jsp?start=+th ePlayer.getPosition();thePlayer.play(false);,/ onBufferFull: function () alert( 视频缓冲完成!+thePlayer.getPosition(); ,onError: function (obj)/jwplayer().load(file:fielUr
10、l,image:imageUrl);/validate();/var position=thePlayer.getPosition();/var9gl2LlJw&e=1426213413;/url2=document.getElementById(info).innerHTML;/alert(lhc url2:+url2+position:+position);/thePlayer.load(file:url2,start:position, provider: http);,/onMeta: function (obj) alert(obj);,/onBeforePlay:function
11、(obj) alert(onBeforePlay);,/onTime:function (obj)alert(onTime:+thePlayer.getPosition()+0.01);,onSeek:function (obj)var9gl2LlJw&e=1426213413;/url2=document.getElementById(info).innerHTML;alert(lhc url2:+url2+position:+position);thePlayer.load(file:url2,provider: http);,/onFullscreen: function (obj) i
12、f (obj.fullscreen) alert(全屏) else alert(非 全屏 ); ,/onMute: function (obj) console.log( 静音 /取消静音 ) ,/onIdle: function () console.log( 空闲 ) /controls:false/skin:skin/facebook.zip);/ 播放暂停$(.player-play).click(function() if (thePlayer.getState() != PLAYING) thePlayer.play(true);this.value = 暂停; else theP
13、layer.play(false);this.value = 播放;);/ 停止$(.player-stop).click(function() thePlayer.stop(); );/ 获取状态$(.player-status).click(function() var state = thePlayer.getState();var msg;switch (state) case BUFFERING:msg = 加载中;break;case PLAYING:msg = 正在播放;break;case PAUSED:msg = 暂停 ;break;case IDLE:msg = 停止;br
14、eak;alert(msg););/ 获取播放进度$(.player-current).click(function() alert(thePlayer.getPosition(); );/ 跳转到指定位置播放$(.player-goto).click(function() if (thePlayer.getState() != PLAYING) /若当前未播放,先启动播放器/ thePlayer.play();thePlayer.seek(600); /从指定位置开始播放(单位:秒);/ 获取视频长度$(.player-length).click(function() alert(thePlayer.getDuration(); ););11 / 11# / 11