为了重新启动我们的视频点播系统,我必须实现闪存流,但要么是因为我以前没有使用过与闪存相关的系统,要么是因为我太笨了,我无法让系统按照它的要求工作。
我们需要:
每个文件的
f 211
我已经有了流和带宽检查工作,我只是似乎无法使访问控制工作。我不知道如何知道哪个文件被回放,也不知道如何根据客户端发送的密钥来回放文件。
服务器端代码(main.asc):
application.onAppStart = function()
{
trace("Starting application");
this.payload = new Array();
for (var i=0; i < 1200; i++) {
this.payload[i] = Math.random(); //16K approx
}
}
application.onConnect = function( p_client, p_autoSenseBW )
{
p_client.writeAccess = "";
trace("client at : " + p_client.uri);
trace("client from : " + p_client.referrer);
trace("client page: " + p_client.pageUrl);
// try to get something from the query string: works
var i = 0;
for (i = 0; i < p_client.uri.length; ++i)
{
if (p_client.uri[i] == '?')
{
++i;
break;
}
}
var loadVars = new LoadVars();
loadVars.decode(p_client.uri.substr(i));
trace(loadVars.toString());
trace(loadVars['foo']);
// And accept the connection
this.acceptConnection(p_client);
trace("accepted!");
//this.rejectConnection(p_client);
// A connection from Flash 8 & 9 FLV Playback component based client
// requires the following code.
if (p_autoSenseBW)
{
p_client.checkBandwidth();
}
else
{
p_client.call("onBWDone");
}
trace("Done connecting");
}
application.onDisconnect = function(client)
{
trace("client disconnecting!");
}
Client.prototype.getStreamLength = function(p_streamName) {
trace("getStreamLength:" + p_streamName);
return Stream.length(p_streamName);
}
Client.prototype.checkBandwidth = function() {
application.calculateClientBw(this);
}
application.calculateClientBw = function(p_client)
{
/* lots of lines copied from an adobe sample, appear to work */
}客户端代码:
<head>
<script type="text/javascript" src="flowplayer-3.1.4.min.js"></script>
</head>
<body>
<a
class="rtmp"
href="rtmp://xx.xx.xx.xx/vod_project/test_flv.flv"
style="display: block; width: 520px; height: 330px"
id="player">
</a>
<script>
$f(
"player",
"flowplayer-3.1.5.swf",
{
clip: {
provider: 'rtmp',
autoPlay: false,
url: 'test_flv'
},
plugins: {
rtmp: {
url: 'flowplayer.rtmp-3.1.3.swf',
netConnectionUrl: 'rtmp://xx.xx.xx.xx/vod_project?foo=bar'
}
}
}
);
</script>
</body>我的第一个想法是从查询字符串中获取一个键,询问web服务该键用于哪个文件和用户,并播放该文件,但我似乎无法从服务器端找到如何播放文件。
我的第二个想法是让flowplayer播放一个文件,将键作为查询字符串传递,如果文件名和键不匹配,则拒绝连接,但我似乎无法找到它当前正在播放的文件。
我剩下的唯一想法是:创建允许用户打开和设置allowReadAccess的所有文件的列表,或者不管调用它是为了允许这些文件,但由于当前的基础结构,这将是笨拙的。
有什么暗示吗?
谢谢。
发布于 2010-04-29 08:11:01
我今天找到了FlowPlayers clip.connectionArgs,现在正在为它实现一个解决方案。
由此产生的守则将大致如下:
服务器端main.asc onConnect:
application.onConnect( p_client, p_userid, p_streamname )
{
if (p_client.check_access(p_userid, p_streamname))
{
p_client.readAccess = "streams/_definst_/" + p_streamname;
this.acceptConnection(p_client);
}
else
{
this.rejectConnection(p_client);
}
}客户端:
$f(
"player",
"flowplayer-3.1.5.swf",
{
clip: {
provider: 'rtmp',
autoPlay: false,
url: 'test_flv',
connectionArgs: ["12345", "test_flv"]
},
plugins: {
rtmp: {
url: 'flowplayer.rtmp-3.1.3.swf',
netConnectionUrl: 'rtmp://xx.xx.xx.xx/vod_project?foo=bar'
}
}
}
);https://stackoverflow.com/questions/2729911
复制相似问题