1.具体的流媒体服务器的搭建参考博客:
http://blog.chinaunix.net/uid-20639775-id-154556.html
具体可能编译的时候有个地方报错
/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function ‘ngx_streaming_handler’:
/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:158: error: ‘ngx_http_request_t’ has no member named ‘zero_in_uri’
make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1
make[1]: Leaving directory `/root/nginx-0.8.54'
make: *** [build] Error 2
,需要注释或者删除一个地方
将src/ngx_http_streaming_module.c文件中以下代码删除或者是注释掉就可以了:
/* TODO: Win32 */
if (r->zero_in_uri)
{
return NGX_DECLINED;
}
2.然后就是jw_player的使用,我们先了解下jw_Player的预留js的回调函数
flashplayer: "player.swf",
file: 'http://localhost/222.mp4',
autostart: "true",
bufferlength: '20',
width: '400',
height: '400',
image: '111.jpg',
events: {
onComplete: function () { console.log("播放结束!!!"); },
onVolume: function () { console.log("声音大小改变!!!"); },
onReady: function () { console.log("准备就绪!!!"); },
onPlay: function () { console.log("开始播放!!!"); },
onPause: function () { console.log("暂停!!!"); },
onBufferChange: function () { console.log("缓冲改变!!!"); },
onBufferFull: function () { console.log("视频缓冲完成!!!"); },
onError: function (obj) { console.log("播放器出错!!!" + obj.message); },
onFullscreen: function (obj) { if (obj.fullscreen) { console.log("全屏"); } else { console.log("非全屏"); } },
onMute: function (obj) { console.log("静音/取消静音") }
}
});
player.onBufferFull(function () { alert("视频缓冲完成!!!"); });
player.onError(function (obj) { alert("播放器出错!!!" + obj.message); })
player.onFullscreen(function (obj) {
if (obj.fullscreen) { alert("全屏"); }
else { alert("非全屏"); }
});
player.onMute(function (obj) { }) // obj. mute是否静音
player.onPlaylist(function (obj) { //视频列表载入完成
alert(obj.playlist[0]['file']);
});
var callback = function () { alert("callback");};//定义一个回调方法
player.onPlaylistItem(callback) // 开始播放一个视频时触发obj.index为视频索引
player.onReady(callback) //准备就绪
player.onResize(callback) //obj.width obj.height 宽高
//进入播放时触发obj.oldstate 值:从BUFFERING PAUSE状态进入播放状态
player.onPlay(callback)
//进入暂停obj.oldstate 值1:从PLAYING BUFFERING状态进入暂停
player.onPause(callback)
player.onBuffer(callback) //进入加载obj.oldstate 值PLAYING, PAUSED or IDLE
player.onIdle(callback) //进入空闲obj.oldstate 值PLAYING, PAUSED or BUFFERING.
player.onComplete(callback) //结束播放
player.onVolume(callback) //obj.volume
player.onPlay(function () {
console.log(this.getPosition());
});
thePlayer = jwplayer( 'container').setup({
$.cookie($("#sectionId").text()+"sectionTime"))/100);
//这个关闭页面或者刷新的时候获取视频的播放进度存入cookie,,如果切换视频,但是无网页刷新的话,是不能记忆的,具体场景具体实现。
});