1

FLEX で構築されたシンプルなビデオ/チャット アプリケーションがあります。さまざまな機能のために、groupSpecifier、netGroup、および NetStream を作成しました。

NetGroupは、主にメッセージ (投稿) と、入力したユーザーの追跡に使用されます。

NetStreamは、同じグループに属する全員の「ビデオの開始、ビデオの停止」などの機能を制御するために使用されます (または使用される可能性があります)。

ここに投稿する最も重要な機能。1 つ目は setupGroup です。

private function setupGroup():void{
    var groupspec:GroupSpecifier = new GroupSpecifier("vid"+GROUP_ID+"_sid_"+SESSION_ID);
    groupspec.serverChannelEnabled = true;
    groupspec.postingEnabled = true;
    groupspec.multicastEnabled = true;
    groupspec.ipMulticastMemberUpdatesEnabled = true;

    trace("Groupspec: "+groupspec.groupspecWithoutAuthorizations());

    netGroup = new NetGroup(nc,groupspec.groupspecWithoutAuthorizations());
    netGroup.addEventListener(NetStatusEvent.NET_STATUS,netStatus);

    netVideo = new NetStream(nc,groupspec.groupspecWithoutAuthorizations());
    netVideo.addEventListener(NetStatusEvent.NET_STATUS,netStatus);

    user = "user"+Math.round(Math.random()*10000);
}

2番目はsendMessageです

private function sendMessage():void{

    var message:Object = new Object();
    message.sender = netGroup.convertPeerIDToGroupAddress(nc.nearID);
    message.user = txtUser.text;
    message.text = txtMessage.text;

    netGroup.post(message);
    receiveMessage(message);

    txtMessage.text = "";
}

そして、ビデオを開始します

private function startVideo():void{
    netVideo.send("publishVideo");
    ns.togglePause();
}

グループ内の残りのメンバーに対して呼び出されることを期待する「publishVideo」と呼ばれる別の機能がありますが、これは行われていません。このコードのほとんどは、Tom がhttp://www.flashrealtime.comから提供した例から直接引用したものです。ヘルプ/提案をいただければ幸いです。

ps 遅延のため、グループ オブジェクトのレプリケーションは使用していません。

4

1 に答える 1

0

答えは非常に単純です。

ビデオを次のように開始する必要があります。

netVideo.publish("channel");

NetStream.send()NetStream.clientレシーバーオブジェクトでコールバックメソッドを呼び出すためのものです。

http://www.flashrealtime.com/multicast-explained-flash-101-p2p/

于 2011-06-08T09:36:49.533 に答える