Highlighted

Loop an externally linked video

Community Beginner ,
Jun 25, 2019

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!

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

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");

}

Views

184

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Loop an externally linked video

Community Beginner ,
Jun 25, 2019

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!

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

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");

}

Views

185

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 25, 2019 0
Adobe Community Professional ,
Jun 26, 2019

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0
Community Beginner ,
Jun 26, 2019

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!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0
Adobe Community Professional ,
Jun 26, 2019

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0
Community Beginner ,
Jun 26, 2019

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 26, 2019 0
Adobe Community Professional ,
Jun 27, 2019

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 27, 2019 1
Community Beginner ,
Jun 27, 2019

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();

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 27, 2019 0
Adobe Community Professional ,
Jun 28, 2019

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");

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 28, 2019 0