4.11 RTMP点播

 

RTMP(Real Time Messaging Protocol)实时消息传送协议是Adobe Systems公司为Flash播放器和服务器之间音频、视频和数据传输开发的私有协议。

本播放器,既支持http协议,也rtmp协议。并且只须设置rtmp服务器JcScpServer参数,即可,很方便,其它代码不变。

 

例(4.11)-1:rtmp协议下的播放器调用代码示例

<script type="text/javascript" src="/player/js/swfobject.js"></script>
<div class="video" id="CuPlayer"> <b> <img src="/player/images/loading.gif" /> 网页视频播放器加载中,请稍后...</b> </div>
<script type="text/javascript">
var so = new SWFObject("/player/player.swf","ply","980","460","9","#000000");
so.addParam("allowfullscreen","true");
so.addParam("allowscriptaccess","always");
so.addParam("wmode","opaque");
so.addParam("quality","high");
so.addParam("salign","lt");
<!-- HTML代码参数/Begin -->
so.addVariable("JcScpServer","rtmp://www.yourServer.com/vod"); //rtmp流媒体服务器地址
so.addVariable("JcScpVideoPath","mp4:test.mp4"); //文件地址
so.addVariable("JcScpImg","/player/images/startpic.jpg"); //视频缩略图
so.addVariable("JcScpFile","/player/CuSunV3Set.xml"); //配置文件
<!-- HTML代码参数/End -->
so.write("CuPlayer");
</script>

 

例(4.11)-2:rtmp协议下的播放器调用代码示例

<script type="text/javascript" src="/player/js/swfobject.js"></script>
<div class="video" id="CuPlayer"> <b> <img src="/player/images/loading.gif" /> 网页视频播放器加载中,请稍后...</b> </div>
<script type="text/javascript">
var so = new SWFObject("/player/player.swf","ply","980","460","9","#000000");
so.addParam("allowfullscreen","true");
so.addParam("allowscriptaccess","always");
so.addParam("wmode","opaque");
so.addParam("quality","high");
so.addParam("salign","lt");
<!-- HTML代码参数/Begin -->
so.addVariable("JcScpServer","rtmp://www.yourServer.com/vod"); //这一行注释掉(rtmp流媒体服务器地址)
so.addVariable("JcScpVideoPath","mp4:2016/06/test.mp4"); //文件地址
so.addVariable("JcScpImg","/player/images/startpic.jpg"); //视频缩略图
so.addVariable("JcScpFile","/player/CuSunV3Set.xml"); //配置文件
<!-- HTML代码参数/End -->
so.write("CuPlayer");
</script>

 

例(4.11)-3:rtmp协议下的播放器调用代码示例

第1部分:

<script type="text/javascript" src="/player/js/swfobject.js"></script>
<div class="video" id="CuPlayer"> <b> <img src="/player/images/loading.gif" /> 网页视频播放器加载中,请稍后...</b> </div>
<script type="text/javascript">
var so = new SWFObject("/player/player.swf","ply","980","460","9","#000000");
so.addParam("allowfullscreen","true");
so.addParam("allowscriptaccess","always");
so.addParam("wmode","opaque");
so.addParam("quality","high");
so.addParam("salign","lt");
<!-- HTML代码参数/Begin -->
so.addVariable("JcScpFile","/player/CuSunV3Set.xml"); //配置文件
<!-- HTML代码参数/End -->
so.write("CuPlayer");
</script>

 

第2部分,以下是配置文件CuSunV3Set.xml代码如下 :

......
<Flashvars_Set
JcScpServer ="http://www.yourServer.com/vod"
JcScpVideoPath="mp4:test.mp4"

ShowJcScpAFront = "yes"
JcScpCountDowns = "10"
JcScpCountDownsPosition = "top-right"
......
......