使用 Adob​​e Cirrus 的 netStream 状态事件问题

发布于 2024-10-14 19:03:29 字数 1143 浏览 8 评论 0原文

基本上我会尝试总结一下。我有一堆潜在的随机字符串用于 recvStream.play("randomstring");

然后我有一个计时器每 5 秒检查一次运行事件侦听器的函数:

recvStream.addEventListener(NetStatusEvent.NET_STATUS,
    netConnectionHandler);

然后我在 switch 语句中思考我可以使用它来检查它是否是活动流,或者让它搜索另一个应该活动的流或停止计时器并让它播放。

    // i was thinking this would verify it's playing and then that's it
         case "NetStream.Play.Start" :
            trace("ITS PLAYING YOU SHOULD SEE SOMETHING");
            timer.stop();
                        break;

         // i was thinking i could use this to see if the string is nothing then the timer would run again
         case "NetStream.Buffer.Empty" :
            trace("THE BUFFER IS EMPTY KEEP LOOKING");
                        //code to look again
            break;

//I also tried NetStream.Play.StreamNotFound instead of NetStream.Buffer.Empty didn't work either

但事实并非如此。我应该使用其他东西来代替 NetStream.Buffer.Empty 吗?还是其他什么东西都在一起?

我在 Flash CS5 中使用 Actionscript 3,并且使用 Cirrus RTMFP http://labs.adobe.com/technologies/cirrus/

Basically i'll try and sum this up. I have a bunch of potential random strings for recvStream.play("randomstring");

then i have a timer checking every 5 seconds on a function that runs an event listener:

recvStream.addEventListener(NetStatusEvent.NET_STATUS,
    netConnectionHandler);

then im thinking in a switch statement i can use it to check if it's an active stream or not to either have it search for another stream that should be active or stop the timer and let it play.

    // i was thinking this would verify it's playing and then that's it
         case "NetStream.Play.Start" :
            trace("ITS PLAYING YOU SHOULD SEE SOMETHING");
            timer.stop();
                        break;

         // i was thinking i could use this to see if the string is nothing then the timer would run again
         case "NetStream.Buffer.Empty" :
            trace("THE BUFFER IS EMPTY KEEP LOOKING");
                        //code to look again
            break;

//I also tried NetStream.Play.StreamNotFound instead of NetStream.Buffer.Empty didn't work either

But it really doesn't work like that. Is there something else I should be using instead of NetStream.Buffer.Empty ? Or something else all together?

I'm using Actionscript 3 in Flash CS5 and I'm using Cirrus RTMFP
http://labs.adobe.com/technologies/cirrus/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ζ澈沫 2024-10-21 19:03:29

我不明白为什么当您附加了一个侦听器来告诉您流的状态时,您为什么要让计时器检查流:

recvStream.addEventListener(NetStatusEvent.NET_STATUS,
    netStatusHandler);

// some code

private function netStatusHandler (ev:NetStatusEvent) : void {

    if (ev.info.level == "error") {
        trace ("Something went wrong. Try again!");
        // call restart method here
        return;
    }

    switch (ev.info.code) {
        case "NetStream.Play.Start" :
            trace("IT'S PLAYING YOU SHOULD SEE SOMETHING");
            break;

        case "NetStream.Buffer.Empty" :
            trace("THE BUFFER IS NOW EMPTY.");
            break;

        // ... any other netstatus events you want to react upon.
    }
}

显然,您还应该考虑在您之前验证随机字符串的正确性调用recvStream.play() - 这比故意让NetStream失败更干净,并且不会造成网络压力。

I don't get why you'd have a timer check the stream, when you have a listener attached to tell you about its status:

recvStream.addEventListener(NetStatusEvent.NET_STATUS,
    netStatusHandler);

// some code

private function netStatusHandler (ev:NetStatusEvent) : void {

    if (ev.info.level == "error") {
        trace ("Something went wrong. Try again!");
        // call restart method here
        return;
    }

    switch (ev.info.code) {
        case "NetStream.Play.Start" :
            trace("IT'S PLAYING YOU SHOULD SEE SOMETHING");
            break;

        case "NetStream.Buffer.Empty" :
            trace("THE BUFFER IS NOW EMPTY.");
            break;

        // ... any other netstatus events you want to react upon.
    }
}

Obviously, you should also consider validating your random string's correctness before you even call recvStream.play() - which would be cleaner than deliberately letting your NetStream fail, and not strain the network.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文