Red5流flv文件

时间:2009-04-23 18:41:50

标签: stream flv red5

我正在检查Red5中的oflaDemo。 我想知道如何更改oflaDemo以便我可以将某个flv文件传输给所有订阅者......

/** {@inheritDoc} */
    @Override
    public boolean appConnect(IConnection conn, Object[] params) {
        // Trigger calling of "onBWDone", required for some FLV players
        measureBandwidth(conn);
        if (conn instanceof IStreamCapableConnection) {
            IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
            SimpleConnectionBWConfig bwConfig = new SimpleConnectionBWConfig();
            bwConfig.getChannelBandwidth()[IBandwidthConfigure.OVERALL_CHANNEL] =
                1024 * 1024;
            bwConfig.getChannelInitialBurst()[IBandwidthConfigure.OVERALL_CHANNEL] =
                128 * 1024;
            streamConn.setBandwidthConfigure(bwConfig);
        }

            serverStream = StreamUtils.createServerStream(appScope, "live0");
            SimplePlayItem item = new SimplePlayItem();
            item.setStart(0);
            item.setLength(10000);
            item.setName("IronMan");
            serverStream.addItem(item);
            item = new SimplePlayItem();
            item.setStart(20000);
            item.setLength(10000);
            item.setName("DarkKnight");
            serverStream.addItem(item);
            serverStream.start();
            serverStream.setRepeat(true);

        return super.appConnect(conn, params);
    }

上面代码的结果只是所有订阅者的空白屏幕......

你们有谁有任何想法?

提前感谢!

2 个答案:

答案 0 :(得分:0)

这在客户端更容易实现,如果您不想对流名称进行硬编码,则可以将其名称作为flash var传递。

答案 1 :(得分:0)

我遇到了同样的问题。我发现空白屏幕是因为什么行

serverStream.setRepeat(true);

如果将repeat设置为false,则一切正常

<强> UPD: 我认为这是red5 bug。我做了一个黑客,不断重复一次。我添加了自定义播放列表控制器:

public class MyPlayListController implements IPlaylistController {
    @Override
    public int nextItem(IPlaylist playlist, int itemIndex) {
        return 0;
    }

    @Override
    public int previousItem(IPlaylist playlist, int itemIndex) {
        return 0;
    }
}