Copy link to clipboard
Copied
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.
use your flv's url to assign the source of your flvplayback component or add to the play method of your netstream class.
Copy link to clipboard
Copied
use your flv's url to assign the source of your flvplayback component or add to the play method of your netstream class.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
your url is incorrect.
Copy link to clipboard
Copied
why is it wrong? that is where my flv is located.
What is the correct URL then?
Copy link to clipboard
Copied
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);
}
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
no, using a 197mb flv won't cause that problem. using a large flv can cause problems but not the problem you're seeing.
Copy link to clipboard
Copied
the code on message 5 worked if I don't change the URL....if I change it I get the streamnotfound message.
Copy link to clipboard
Copied
case counts online. fix your case problems.
also, if your swf is in that root directory, use a relative path: "videos/priimeiraquinta.fla"
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
click that refresh button on your ftp client to make sure that flv is still in videos and still has the same name.
Copy link to clipboard
Copied
I clicked but it didn't work.
Copy link to clipboard
Copied
what do you mean, it didn't work.
did the refresh button show your flv is still on your server in your videos directory?
Copy link to clipboard
Copied
Yes, I clicked the refresh button and the flv file is in there...
Copy link to clipboard
Copied
you could check your server's mime types to make sure it knows how to handle flv files.
Copy link to clipboard
Copied
How do I do this?
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
use a timer or enterframe loop.
make sure you grant internet privileges for your android app.
Copy link to clipboard
Copied
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
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now