0

I need to play multiple (66) synchronized .flv videos in flash. What I do:

I create a new NetConnection (one for all NetStreams)

var connection: NetConnection,
clipper: MovieClip;
connection = new NetConnection();
connection.connect(null);

I have a function to create all the netstream

function addCamera(id, url, pos_x, pos_y) {
    var player: Video = new Video(stageSize.x, stageSize.y),
        stream: NetStream,
        clip: MovieClip;
    clip = new MovieClip();
    stage.addChildAt(clip, 0)
    stream = new NetStream(connection);
    stream.client = this;
    clip.addChild(player);
    player.attachNetStream(stream);
    stream.bufferTime = 1;
    stream.receiveAudio(false);
    stream.receiveVideo(true);
    stream.inBufferSeek = true;
    stream.play(url)
    player.visible = false;

    if (!camera[pos_x]) {
        camera[pos_x] = [];
        trace("new camera row:" + pos_x.toString());
        planeSize[0] = planeSize[0] + 1;
    }
    trace("new camera: [" + pos_x.toString() + ", " + pos_y.toString() + "]");
    camera[pos_x][pos_y] = {
        "stream": stream,
        "player": player,
        "pos_x": pos_x,
        "pos_y": pos_y,
        "buffered": false,
        "buffer": 0,
        "id": id
    }

Only one video is visible at a time:

camera[currentCamera[0]][currentCamera[1]].player.visible = true;

(rest has .visible=false)

This works great for new computers, but on older ones it's a nightmare. Is it possible to have the hidden videos keep their timestamps going on, but for the flash not to render them?

Also, when I seek:

function seekTo(time) {
    trace("Seek to: " + time.toString());
    for each(var pos_x in camera) {
        for each(var curCamera in pos_x) {
            seeking = true;
            curCamera.stream.seek(time);
        }
    }
}

it takes a while.

Michal
  • 733
  • 2
  • 6
  • 23

1 Answers1

1

Try to only add the videos to the DisplayList when there are meant to be visible.

Orrrr.

Have one MovieClip as your player:

var currentClip:MovieClip = new MovieClip();

and add it to the stage.

Then the clips that are being added in the addCamera function (don't stage.addChild here), push them into a Vector

Then when you want a specific clip to be played, reference currentClip to a clip in the Vector that is to be shown.


As for seeking, Maybe try to have a Vector of the streams that references all the streams and loop through seeking each one of those...

I takes a little time to get the stream object from each camera. Also this way you only need one for loop instead of a nested. It will take up more memory tho a reference of each stream in a Vector.

Michael Freytag
  • 154
  • 1
  • 11
Travis
  • 461
  • 3
  • 7