Copy link to clipboard
Copied
Hello,
I would lile to endlessly loop a externally linked video file which acts as a background layer.
Here is my current functioning code :
import flash.net.NetConnection;
import flash.net.NetStream;
var myConnection:NetConnection = new NetConnection();
var myStream:NetStream;
var metaInfo:Object = new Object();
myConnection.connect(null);
myStream = new NetStream(myConnection);
myVideo.attachNetStream(myStream);
myStream.play("myVideo.mp4");
metaInfo.onMetaData = onMetaData;
myStream.client = metaInfo;
function onMetaData(info:Object):void{
}
How can unable the video for it to loop seamlessly?
Thanks in advance!
use:
function statusHandler(event: NetStatusEvent): void {
switch (event.info.code) {
case "NetStream.Play.Start":
trace("Start [" + myStream.time.toFixed(3) + " seconds]");
break;
case "NetStream.Play.Stop":
trace("Stop [" + myStream.time.toFixed(3) + " seconds]");
completeF(event);
break;
}
}
function completeF(e: Event): void {
myStream.seek(0)
myStream.play(("séquence_justice.mp4");
}
Copy link to clipboard
Copied
you can check for the end of your netstream and then restart it but it won't be seamless unless you edit the end of the video to go black.
Copy link to clipboard
Copied
I have pinpointed the end of the NetStream but I can't seem to find a way to restart it. Here is my current code:
myConnection.connect(null);
myStream = new NetStream(myConnection);
séquence_justice.attachNetStream(myStream);
myStream.play("séquence_justice.mp4");
metaInfo.onMetaData = onMetaData;
myStream.client = metaInfo;
function onMetaData(info:Object):void{
}
myStream.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
function statusHandler(event:NetStatusEvent):void
{
switch (event.info.code)
{
case "NetStream.Play.Start":
trace("Start [" + myStream.time.toFixed(3) + " seconds]");
break;
case "NetStream.Play.Stop":
trace("Stop [" + myStream.time.toFixed(3) + " seconds]");
break;
}
}
The output information I get form this is the following:
Start [0.000 seconds]
Stop [33.433 seconds]
Thanks!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I have read this post and to my understanding, it says that it should work using the following code + with a H.264 mp4 video (not a .mov file) also that is has to be a as3 project :
import fl.video.VideoEvent;
function completeF(e: fl.video.VideoEvent): void {
séquence_justice.seek(0)
séquence_justice.play();
}
Unfortunitely I get the 1046 error message : Type was not found or was not compile-time constant.
Do you know what I'm doing wrong?
Copy link to clipboard
Copied
use
import flash.events.VideoEvent
call completeF from statushandler (and fix its event)
and you should be rewinding and playing the netstream, not the video object.
Copy link to clipboard
Copied
Thanks, I'm slowly getting there. Sorry, I'm new to AS3.
Using import flash.events.VideoEvent and + the netstream instead of video.
Calling completeF from statushandler is an other story. Here's what I currently have :
import flash.events.VideoEvent
myStream.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
function statusHandler(event:NetStatusEvent):void{
switch (event.info.code)
{
case "NetStream.Play.Start":
trace("Start [" + myStream.time.toFixed(3) + " seconds]");
break;
case "NetStream.Play.Stop":
trace("Stop [" + myStream.time.toFixed(3) + " seconds]");
break;
}
}
// TRYING TO CALL statusHandler FUNCTION with : myStream.addEventListener(Event.CONNECT,statusHandler)
myStream.addEventListener(Event.CONNECT,statusHandler)
function completeF(e: flash.events.VideoEvent): void {
myStream.seek(0);
myStream.play();
}
Copy link to clipboard
Copied
use:
function statusHandler(event: NetStatusEvent): void {
switch (event.info.code) {
case "NetStream.Play.Start":
trace("Start [" + myStream.time.toFixed(3) + " seconds]");
break;
case "NetStream.Play.Stop":
trace("Stop [" + myStream.time.toFixed(3) + " seconds]");
completeF(event);
break;
}
}
function completeF(e: Event): void {
myStream.seek(0)
myStream.play(("séquence_justice.mp4");
}