2

ビデオ オン デマンド システムの再起動のためにフラッシュ ストリーミングを実装する必要がありますが、これまでフラッシュ関連のシステムを使用したことがないためか、あまりにも愚かであるために、システムを正常に機能させることができません。

必要なもの:

  • 1 分ごとに WebService をチェックして、ファイルごとおよびユーザーのアクセス制御を行う
  • ストリームの途中でリース時間が切れた場合: ストリームのキャンセル
  • rtmp ストリーミング
  • 動的帯域幅チェック
  • Flowplayer でのビデオ再生 (既存のライセンス)

ストリーミングと帯域幅のチェックは機能していますが、アクセス制御が機能していないようです。クライアントから送信されたキーに応じて、どのファイルが再生されるか、またはファイルを再生する方法を知る方法がわかりません。

サーバー側コード (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サービスに問い合わせてファイルを再生することでしたが、サーバー側からファイルを再生する方法がわかりません。

私の2番目のアイデアは、flowplayerにファイルを再生させ、キーをクエリ文字列として渡し、ファイル名とキーが一致しない場合は接続を拒否することでしたが、現在再生中のファイルを見つけることができないようです.

私が持っている唯一のアイデアは、ユーザーが開くことを許可されているすべてのファイルのリストを作成して allowReadAccess を設定するか、それらのファイルを許可するために呼び出されたが、現在のインフラストラクチャのために扱いにくいことです。

ヒントはありますか?

ありがとう。

4

1 に答える 1

0

今日、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'
       }
     }
   }
);
于 2010-04-29T08:11:01.567 に答える