• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Loop an externally linked video

Community Beginner ,
Jun 25, 2019 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!

Views

330

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
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 28, 2019 Jun 28, 2019

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

}

Votes

Translate

Translate
Community Expert ,
Jun 26, 2019 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.

Votes

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
community guidelines
Community Beginner ,
Jun 26, 2019 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!

Votes

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
community guidelines
LEGEND ,
Jun 26, 2019 Jun 26, 2019

Copy link to clipboard

Copied

Votes

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
community guidelines
Community Beginner ,
Jun 26, 2019 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?

Votes

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
community guidelines
Community Expert ,
Jun 27, 2019 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.

Votes

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
community guidelines
Community Beginner ,
Jun 27, 2019 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();

}

Votes

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
community guidelines
Community Expert ,
Jun 28, 2019 Jun 28, 2019

Copy link to clipboard

Copied

LATEST

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

}

Votes

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
community guidelines