Solved

How to load local FLV file into a movieclip?

Posted on 2004-03-24
4
810 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
SandyCooke earned 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

630 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