4.11 RTMP直播

 

 

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

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

 

RTMP直播范例:

网页视频播放器加载中,请稍后...

 

例(4.12)-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/live"); //您的rtmp流媒体服务器地址
so.addVariable("JcScpVideoPath","livestream"); //流名称
so.addVariable("JcScpImg","/player/images/startpic.jpg"); //视频缩略图
so.addVariable("JcScpFile","/player/CuSunV3Set.xml"); //配置文件
<!-- HTML代码参数/End -->
so.write("CuPlayer");
</script>

 

例(4.12)-2: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代码如下(直播时,把JcScpLiveMode直播模式值设为 1,隐藏进度条):

<CuPlayer>
<Player_Set
JcScpBufferTime = "5"
JcScpVolume = "75"
JcScpCode = "utf8"
JcScpImgDisplay = "no"
JcScpAutoHideControl ="yes"
JcScpControlHideTime="0.5"
JcScpControlHeight="40"
JcScpShowList= "yes"
JcScpAutoRepeat = "no"
JcScpsetMode = "1"
JcScpAFrontCanClose = "no"
JcScpShowRightmenu = "yes"
JcScpShareMode = "JcScpVideoPath"
JcScpLoadbarMode = "0"
JcScpLiveMode = "1"
/>
<Logo_Set
JcScpLogoDisplay = "yes"
JcScpLogoPath = "images/logo.png"
JcScpLogoPosition = "top-left"
JcScpLogoWidth = "165"
JcScpLogoHeight = "75"
JcScpLogoAlpha = "1"
/>
<Flashvars_Set
JcScpServer ="rtmp://www.yourServer.com/live"
JcScpVideoPath = "livestream"
JcScpVideoPathHD = ""
JcScpImg ="images/startpic.jpg"
JcScpAutoPlay = "yes"
JcScpStarTime = "0"
JcScpEndTime = "0"
JcScpCuePointInfo = ""
JcScpCuePointTime = ""
......
......