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

Load a flv file from the net.How?

Community Beginner ,
Dec 23, 2013 Dec 23, 2013

Hi!

I need to create a video player that will load the FLV file from the net.Can Anyone please give me an example of how do I do it?

I've tried a lot of codes but none of them worked for me.

TOPICS
ActionScript
5.0K
Translate
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 , Dec 23, 2013 Dec 23, 2013

use your flv's url to assign the source of your flvplayback component or add to the play method of your netstream class.

Translate
Community Expert ,
Dec 23, 2013 Dec 23, 2013

use your flv's url to assign the source of your flvplayback component or add to the play method of your netstream class.

Translate
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 ,
Dec 23, 2013 Dec 23, 2013

Hi!

This is the code I am using but it is returning an error message saying " Error opening URL 'http://www.djchambinho.com/Videos/PrimeiraQuinta.flv' NetStream.Play.StreamNotFound

var video:Video = new Video(320, 240);

addChild(video);

var nc:NetConnection = new NetConnection();

nc.connect(null);

var ns:NetStream = new NetStream(nc);

ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);

function onStatusEvent(stat:Object):void

{

          trace(stat.info.code);

}

var meta:Object = new Object();

meta.onMetaData = function(meta:Object)

{

          trace(meta.duration);

}

ns.client = meta;

video.attachNetStream(ns);

ns.play("http://www.djchambinho.com/Videos/PrimeiraQuinta.flv");

thank you

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

your url is incorrect.

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

why is it wrong? that is where my flv is located.

What is the correct URL then?

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

I've tried this code too that I got from flash help adobe's site and it is not working eighter.I've changed the URL and it is saying that StreamNotFound but if I dont change the url it works fine.

package {

    import flash.display.Sprite;

    import flash.events.NetStatusEvent;

    import flash.events.SecurityErrorEvent;

    import flash.media.Video;

    import flash.net.NetConnection;

    import flash.net.NetStream;

    import flash.events.Event;

    public class NetConnectionExample extends Sprite {

        private var videoURL:String = "http://www.helpexamples.com/flash/video/cuepoints.flv";

        private var connection:NetConnection;

        private var stream:NetStream;

        private var video:Video = new Video();       

        public function NetConnectionExample() {

            connection = new NetConnection();

            connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

            connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

            connection.connect(null);

        }

        private function netStatusHandler(event:NetStatusEvent):void {

            switch (event.info.code) {

                case "NetConnection.Connect.Success":

                    connectStream();

                    break;

                case "NetStream.Play.StreamNotFound":

                    trace("Stream not found: " + videoURL);

                    break;

            }

        }

        private function securityErrorHandler(event:SecurityErrorEvent):void {

            trace("securityErrorHandler: " + event);

        }

        private function connectStream():void {

            addChild(video);

            var stream:NetStream = new NetStream(connection);

            stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

            stream.client = new CustomClient();

            video.attachNetStream(stream);

            stream.play(videoURL);

        }

    }

}

class CustomClient {

    public function onMetaData(info:Object):void {

        trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);

    }

    public function onCuePoint(info:Object):void {

        trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type);

    }

}

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

the code in message 5 works for me.

if you change videoURL to "http://www.djchambinho.com/Videos/PrimeiraQuinta.flv" i would expect the message 5 code to fail for the same reason as your message 2 code:  the url is wrong.

you could attach a screenshot of the http://www.djchambinho.com/Videos/ directory to get more specific help about why your url is wrong.

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

it's wrong because when i click it i see 404 error instead of the flv.  i don't know the correct url because i can't inspect your directories.  i can see that you have a Videos directory but i can't see what's in it.

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

but the flv file is inside this directory and this is the correct path.I don't know it is not working? The file has 197MB.Do you think this might be the problem?

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

no, using a 197mb flv won't cause that problem.  using a large flv can cause problems but not the problem you're seeing.

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

the code on message 5 worked if I don't change the URL....if I change it I get the streamnotfound message.

Screen Shot 2013-12-24 at 2.50.47 PM.png

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

case counts online.  fix your case problems.

also, if your swf is in that root directory, use a relative path:  "videos/priimeiraquinta.fla"

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

I've already changed Videos for videos and PrimeiraQuinta for primeiraquinta and changed my code. It did not work. my swf is on my computer yet..I did not upload it yet.But with the url I got from the exemple it worked fine.

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

click that refresh button on your ftp client to make sure that flv is still in videos and still has the same name.

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

I clicked but it didn't work.

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

what do you mean, it didn't work.

did the refresh button show your flv is still on your server in your videos directory?

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

Yes, I clicked the refresh button and the flv file is in there...

Translate
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 ,
Dec 24, 2013 Dec 24, 2013

you could check your server's mime types to make sure it knows how to handle flv files.

Translate
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 ,
Dec 25, 2013 Dec 25, 2013

How do I do this?

Translate
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 ,
Dec 25, 2013 Dec 25, 2013

I've added .flv extension and it worked.Now I need to make a preloader for this video because it is taking too long. How do I do this preloader?

thank you very much!

Translate
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 ,
Dec 25, 2013 Dec 25, 2013

it's funny.When I run it on a computer it works but if I run it on my samsung Android phone it stops working....My app freezes and closes..Dark screen.After I open my app acouple of times I even here some sound but then it stops and doesnt show anyting..if I close my app and open it again then I see the app but no video and no sound

After sometime it is playing but the video has transparence ...

I guess I need to make a preloader or something but I dont know because once I click a button to open the swf file into an empty MC the screen gets dark

Translate
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 ,
Dec 25, 2013 Dec 25, 2013

start the stream and immediately pause it.  use a loop to track the bytesLoaded property of your netstream.

when enough video has loaded to ensure smooth playback, unpause the stream.

and the problems in you android might be because that video is so large.  try testing with a smaller sized flv.

Translate
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 ,
Dec 25, 2013 Dec 25, 2013

is there a method I have to do this loop inside or just make a loop after I put ns.pause()? How would I do this loop?

I have upload a smaller size file to a server and still I get a black screen.

Translate
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 ,
Dec 25, 2013 Dec 25, 2013

use a timer or enterframe loop.

make sure you grant internet privileges for your android app.

Translate
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 ,
Dec 25, 2013 Dec 25, 2013

I'm lost in this timer thing. is it something like this?

var t : Timer = new Timer(ns.bytesTotal,0);

t.addEventListener("timer",timeHandler);

t.start();

function timeHandler(event : TimeEvent) : void

{

// how do I check here to resume the playback

}

Translate
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