有时候要用到在前端Web界面往Flash里面传值,Flash根据获取到的值去播放指定的视频流。
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<%
String meetid = request.getParameter("MeetId");
String key = request.getParameter("Key");
%>
<div align="center">
<object width="200" height="200">
<param name="movie" value="JieShou.swf"></param>
<param name="flashvars" value="xian=<%=key%>"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="JieShou.swf" type="application/x-shockwave-flash"
allowscriptaccess="always" allowfullscreen="true"
flashvars="xian=<%=key%>"> </embed>
</object>
</div>
</body>
</html>
flashvars="xian=<%=key%>"
这里就传递了一个名称为xian值为key,key从页面请求中获取。把这个参数传递给flash,那么flash怎么接受这个参数呢。
看下面代码:
function initRec()
{
var cc = new Object();
cc.onMetaData = onmd;
var flvNmae = loaderInfo.parameters.xian
receiveStream= new NetStream(netConnect2);
receiveStream.client = cc;
function onmd(o : Object):void{}
receiveStream.play(flvName);
rece_video.attachNetStream(receiveStream);
}
这样就获取到了web端传递过来的参数xian.这个xian可以是流媒体的播放key值。用来选择性的点播视频流。
原文链接: http://blog.csdn.net/peijiangping1989/article/details/7248721