D
D
Daniil Bakalin2014-11-12 05:00:40
ActionScript
Daniil Bakalin, 2014-11-12 05:00:40

How to duplicate video stream in ActionScript 3.0?

Good afternoon!
To solve a specific problem, I need to simultaneously show the same video in three places on the screen.
Using standard tools, I can load the same file three times and show it, but problems arise: the file is large, slowdown occurs, and it leads to desynchronization ...
What can be done?
If you just attach'chit the stream to two video areas, then the image is displayed only in the last one. Maybe there is some mechanism for duplicating the video stream?
Just in case, my code is:

var nc:NetConnection = new NetConnection(); 
nc.connect(null); 
var ns:NetStream = new NetStream(nc);
ns.play("1.mp4"); 
myVideo1.attachNetStream(ns);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Bakalin, 2014-11-15
@Quiensabe

The answer was suggested on flasher.ru. Thanks again Partizan! :)
The code below takes a rectangular area of ​​the document and draws it side by side.

import flash.display.BitmapData;
import flash.display.Bitmap;

addEventListener(Event.ENTER_FRAME, copy);
var bd:BitmapData
 
function copy(e:Event):void{
  if(bd)bd.dispose();
  bd = new BitmapData(150,150,true,0xcc00ff00);	
  bd.draw(this);	
  var b:Bitmap = new Bitmap(bd);
  b.x = 200;
  addChild(b);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question