PDA

View Full Version : Netstream & Attachvideo


Moooink
07-28-2004, 05:26 PM
I'm trying to figure out how to use Netstream to dynamically import .flv video clips. I have everything setup, and a mediadisplay called: display.

The code I am using is:

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
display.attachVideo(ns);
ns.play("laura.flv");

forwhatever reason, only audio is playing from my .flv, no video. Also when trying to use Netstream, my controller is no longer linked to my display. Is there some catch that i am missing? I have been saving the swf as flash 6. :confused:

edit: I've also tried it exporting with flash 7. still only audio plays, no video.

adrian_arrakis
07-29-2004, 09:51 AM
To play back an external FLV file in a Flash document:
With the document open in the Flash authoring tool, in the Library panel (Window > Library) select New Video from the Library options menu to create a video object.
Drag a video object from the Library panel onto the Stage. This creates a video object instance.
With the video object selected on the Stage, in the Property inspector (Window > Properties) enter my_video in the Instance Name text box.
Open the Components panel (Window > Development Panels > Components) and drag a TextArea component to the Stage.
With the TextArea object selected on the Stage, enter status in the Instance Name text box in the Property inspector.
Select Frame 1 in the Timeline, and open the Actions panel (Window > Development Panels > Actions).
Add the following code to the Actions panel:
// Create a NetConnection object:
var netConn:NetConnection = new NetConnection();
// Create a local streaming connection:
netConn.connect(null);
// Create a NetStream object and define an onStatus() function:
var netStream:NetStream = new NetStream(netConn);
// Attach the NetStream video feed to the Video object:
my_video.attachVideo(netStream);
// Set the buffer time:
netStream.setBufferTime(5);
// Being playing the FLV file:
netStream.play("videoFile.flv");

replace the AS code with your own

Moooink
07-29-2004, 12:27 PM
Ok I've run into a new problem now. Actually walking around netstream, i've created a dynamic .flv player that uses media components. It uses display.setmedia("laura.flv"); or something like that, i can't rememebr exactly. The logic works and seems to be able to load dynamically. My issue now is a question as to why the seek bar is not functionable. It only seems to stay stuck on the right side. Here is the example of the .swf

http://www.seminolewarhawkband.com/audio/jazzband/asdf.swf?file=laura.flv&band=band&track=track

EDIT: Actaully it appears to work fine. Might have been a cache issue. :cool:

markus79
10-07-2005, 09:09 PM
I am also having trouble getting the video to show up. The audio plays, but no video, even though I have it on the timeline. I'm using the code that was given in an above post. Any ideas why I would hear audio but not see video?

Thanx
markus

onirix
10-17-2005, 01:15 PM
The code to use needs to have the length of the video indicated in seconds.

choice="test.swf";
lengthofvideo=231.42;
video.setMedia(choice, "FLV");
video.totalTime = lengthofvideo;

To get the length of the video just import the flv into a different flash fla file and open library, right click on the flv and get properties. You will see the seconds there. I have tried some other softwares that are supposed to detect the correct length, but my way is more accurate.

lordcatalien
10-18-2005, 05:54 PM
Having the same issue. the audio plays, but i can't see the video. the mediaPlayback component's streaming bar and buttons don't work and it doesn't grab the play time.

This leads me to believe that the video is playing somewhere else, somehow. there are only two layers and one frame on my movie. layer one has the below code. layer two has the mediaPlayback component called "my_video". Please help.

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
stream_ns.setBufferTime(15);
var choice = "themoviefile.flv";
this.my_video.contentPath(choice);
stream_ns.time = 39;
stream_ns.play(choice);
this.my_video.attachVideo(stream_ns);

Schiz
12-09-2005, 12:44 PM
i had the same problem. the problem is that flash needed an video object on the scene with the name of the video object. i don't know if this helps you but this is what it said in my book:

3. Open the documentís Library panel (Ctrl+L or ‘+L). In the options menu located at the top-right corner of the panel, choose New Video. After you have selected the option, you should see a new Embedded Video symbol in the Library.

4. Select the keyframe of the layer you want to place the movie on. Drag an instance of the Embedded Video symbol from the Library to the stage. In the Property inspector, name the instance vidWin.

without placing the instance name i only got audio, and with the instance name i had video too..

PhishIn4Dmb
01-24-2006, 10:42 AM
Ok:

Well just so every one knows, when a FLV is streamed or progressiveley loaded into flash the video and audio are considered two different enties. Hence the reason for hearing the audio and not seeing the video.

So far there has been no way to get a dynamical loaded streaming FLV to play in the FLVPlayback component. Atleast none that I could find. The closest I could get was using the XMLloader to bind to the player to pass it a URL string. But that still had some problems for me.

In any case if any one knows how to attach dynamicley streamed FLV to a component then let me know.

Steve

mistergoofletron
03-31-2006, 11:33 PM
1: If you're on a windows 2003 IIS server set the mime type.
http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_19439
2: make a flash movie
3: drag the MediaPlayer component onto the screen
4: give the MediaPlayer an instance name (I'll call it my_playback)
5: put this code on frame 1 of the main timeline:

//parse the url
file_name_start_index=_url.lastIndexOf("file=")+5;
file_name_end_index=_url.indexOf("&",file_name_start_index);
file=_url.substring(file_name_start_index,file_nam e_end_index);

seconds_start_index=_url.lastIndexOf("length=")+7;
seconds_end_index=_url.indexOf("&",seconds_start_index);
seconds=_url.substring(seconds_start_index,seconds _end_index);

last_three=file.substr(-3);
media_type=last_three.toUpperCase();

// Component Inspector
my_movie=_root.movie;

my_playback.autoPlay = true;
my_playback.setMedia(file, media_type);
my_playback.totalTime = seconds;
my_playback.autoSize = true;
// my_playback.aspectRatio = true;
my_playback.controlPlacement = "bottom";
my_playback.controllerPolicy = "on";


5: save your file and upload it to your server. Let's assume that you named it "video_player.swf".

6: Make an .flv file. Let's say it's called "peak_oil_will_kill_your_family.flv".

7: use your favorite scripting language to set those variables in the src= tag of the <embed> tag in the html that's going to hold this flash movie.
So given our stuff above it should look something like this:
src="video_player.swf?file=peak_oil_will_kill_your_fami ly.flv&length=500&".

8: watch an eye-opening video about about Peak Oil.

A great spot that helped me to piece this together is:
http://www.actionscript4designers.com/wmg3/video_media_components.html

dave123williams
05-04-2006, 11:17 PM
Once published and on my server, I should be able to get that to work by just calling this url, right?

http://www.mysite.com/flashplayer.swf?file=stream.flv

FlashChump
03-10-2007, 01:12 PM
To play back an external FLV file in a Flash document:
With the document open in the Flash authoring tool, in the Library panel (Window > Library) select New Video from the Library options menu to create a video object.
Drag a video object from the Library panel onto the Stage. This creates a video object instance.
With the video object selected on the Stage, in the Property inspector (Window > Properties) enter my_video in the Instance Name text box.


Is there a way to do this at runtime? I am trying just New Video() and I am still getting the audio but no video problem.

dannysc
03-23-2007, 01:35 AM
I'm having the audio but no video problem. I'm using loadclip to load an external swf with embedded video. Does the embedded video have to be on the root time line to work?

jho3k
05-28-2009, 03:25 PM
i had the same problem. the problem is that flash needed an video object on the scene with the name of the video object. i don't know if this helps you but this is what it said in my book:


without placing the instance name i only got audio, and with the instance name i had video too..

Thanks, your a freakin' G :cool:

ggalan
10-28-2009, 10:03 PM
does anyone know if you can add a listener when using attachVideo?

this.my_video.attachVideo(stream_ns);