Solved

How to load local FLV file into a movieclip?

Posted on 2004-03-24
4
798 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 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now