?
Solved

How to load local FLV file into a movieclip?

Posted on 2004-03-24
4
Medium Priority
?
820 Views
Last Modified: 2012-06-27
How to load local FLV file into a movieclip? I've found the next code but don't know what to do with it.
---------------------><8-------------------------
// CREATE VIDEO CONNECTION TO LOCAL MACHINE
// Set the name of the movie to be played
 fileName = "Intro.flv";
// Create a NetConnection object:
 var netConn:NetConnection = new NetConnection();
// Create a local streaming connection:
 netConn.connect(null);
// Create a NetStream object
 var netStream:NetStream = new NetStream(netConn);
// Define an onStatus() function:
 netStream.onStatus = function(infoObject) {
  status.text += "Status (NetStream)" + newline;
  status.text += "Level: " + infoObject.level + newline;
  status.text += "Code: " + infoObject.code + newline;
  // Turn on the mouse listener if the movie clip has ended.
  // This is how we are restarting the movie.
  if(infoObject.code == "NetStream.Buffer.Empty"){
   mouseListener = new Object();
   mouseListener.onMouseMove = function(){
    trace('play again');
    // TURN OFF THE MOUSE LISTENER
    Mouse.removeListener(mouseListener);
    // Clear status window
    status.text = "";
    // Replay the video
    playExternalVideo(fileName);
   }; Mouse.addListener(mouseListener);
  }
 };
 function playExternalVideo(fn){
 // Attach the NetStream video feed to the Video object:
  this.my_video.attachVideo(netStream);
  // Set the buffer time (seconds):
  netStream.setBufferTime(5);
  // Begin playing the FLV file: on frame 3 not here.
  netStream.play("media/video/"+fn);
 }
 playExternalVideo(fileName);
---------------------><8-------------------------

I've tried to place it into the movieclip's onLoad() event but with no luck.
Could anybody give me a working FLA or at least actionscript code with accurate instructions what and how to do?

Thanks in advance.
0
Comment
Question by:abb1
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
SandyCooke earned 1500 total points
ID: 10668219
If anyone knows how to script steps 1-3 I would be very interested, but this should help you in the short term:

1) Choose 'New Video' from the Library pane (call it whatever you like)
2) Drag the object from the library to the stage
3) Name the instance (in this example) 'MyVideo'
4) Add this code to the first frame:

myUrl = "montage.flv"; // change this to the path to your FLV file or you won't see owt
//
var myNetConnection:NetConnection = new NetConnection();
myNetConnection.connect(null);
//
var netStream:NetStream = new NetStream(myNetConnection);
//
myVideo.attachVideo(netStream);
netStream.play(myUrl);

This is everything I have learned so far about FLV playback :)

Sandy
0
 
LVL 3

Author Comment

by:abb1
ID: 10668402
I'm really puzzled...

I've just found the same answer in the EE through Google search but EE itself requires a bucks to use EE search engine!
What's a hell!

I understand I must (formally speaking) give these points to you but could you be satisfied if I simply explain what Flash does in fact when you perform the actions 1..3? I've just checked it and the code is pretty short and clear! I would say, it cannot be shorter!
0
 
LVL 2

Expert Comment

by:SandyCooke
ID: 10713391
Hi abb1

I've got a better idea: You give me the points for this question and then you go and tell me how to script a New Video object in my question thread:

http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_20930371.html

This way we both answer a question!

Sandy
0
 
LVL 3

Author Comment

by:abb1
ID: 10729324
It is an iteresting idea to earn expert points for each other :)))

Now I have the next issue: how to synchronize the video playback with other clips (slideshows, etc.). Unfortunately MM doesn't let us to stream slides (like RealMedia does it). Now I have just the only idea - to check NetStream.time and load slides into the slide window (a movieclip) if the time has come.

Also I can't find how to get a total duration of the video currently active. Therefore I don't see a native solution of how to create slider for video navigation. The only idea here is to get the total length information from outside of video (from XML or so).

If you have another and better ideas of how to do that then we could continue our discussin in the another thread.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question