Title: Flash Media Server Streaming: Content Protection
Tags: flash;streaming;flash-media-server;flowplayer
Question: i have to implement flash streaming for the relaunch of our video-on-demand system but either because i haven't worked with flash-related systems before or because i'm too stupid i cannot get the system to work as it has to.
We need:
Per file &amp; user access control with checks on a WebService every minute
if the lease time ran out mid-stream: cancelling the stream
rtmp streaming
dynamic bandwidth checking
Video Playback with Flowplayer (existing license)
I've got the streaming and bandwidth check working, i just can't seem to get the access control working. I have no idea how i know which file is played back or how i can play back a file depending on a key sent by the client.
Server-Side Code (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 &amp; 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 */
Client-Side Code:
<head&gt;
<script type="text/javascript" src="flowplayer-3.1.4.min.js"&gt;</script&gt;
</head&gt;
<body&gt;
<a
class="rtmp"
href="rtmp://xx.xx.xx.xx/vod_project/test_flv.flv"
style="display: block; width: 520px; height: 330px"
id="player"&gt;
</a&gt;
<script&gt;
$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&gt;
</body&gt;
My first Idea was to get a key from the Query String, ask the web service about which file and user that key is for and play the file but i can't seem to find out how to play a file from server side.
My second idea was to let flowplayer play a file, pass the key as query string and if the filename and key don't match then reject the connection but i can't seem to find out which file it's currently playing.
The only remaining idea i have is: create a list of all files the user is allowed to open and set allowReadAccess or however it was called to allow those files, but that would be clumsy due to the current infrastructure.
Any hints?
Thanks.

Here is the accepted answer: I found the FlowPlayers clip.connectionArgs today and i'm implementing a solution for it now.
the resulting Code will be something along the lines of:
Server-Side 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);
Client Side:
"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'
}
}


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2010:00:04/28/10', 'FavoriteCount': 2.0, 'PostTypeId': 1, 'Tags': '<flash><streaming><flash-media-server><flowplayer>', 'Title': 'Flash Media Server Streaming: Content Protection', 'ViewCount': 1647, 'id': 2729911, 'user_AboutMe': '', 'user_AccountId': 92713.0, 'user_DisplayName': 'Morfildur', 'user_Reputation': 12724.0, 'user_Views': 519.0, 'user_id': 253984.0}}