Tutorial details: Loading External Video Using NetConnection and NetStream
Difficulty Level: Intermediate
Requirements: Flash MX 2004
Assumed Knowledge: None
File(s) to Download: flv2_tutorial.zip
Online Example: none
Loading External Video Using NetConnection and NetStream
Until Flash MX2004 came along the thought of being able to load external video directly through Flash was the pipe-dream of mad men. Sure, video could be streamed
using Macromedia Communication Server, but for the majority of people the associated costs meant it was a total non-starter.
Enter Flash MX2004.
I'm sure most of you will already be aware that MX04 comes in two different flavours, "Standard" and "Professional" - and those of us lucky enough
to own MX04 Professional will have access to Media components that can handle both streaming and progressive download.
Before we go any further I'll just clarify some of the main differences between streaming video and progressively downloading it:
Progressive Download - feeding external flv files in to a Flash movie and playing them back at runtime. The file can start playing before it's completely downloaded but the user
must download the whole file and can not skip forward to view parts that haven't been downloaded yet.
Streaming - each client opens a persistant connection back to a video server. As with progressive download the file can start playing before it has finished downloading,
but unlike progressive download the user is not required to download the entire file, in fact the user has the ability to skip to any part of the file without having to download the parts they do not wish to see.
Streams can also be changed on the fly (for example, switch from high to low quality). There are many other benefits of Streaming video including the ability to detect bandwidth, statistic reporting and
added security. Streaming requires Flash Communication Server or the Flash Video Streaming Service (http://www.macromedia.com/go/fvss)
What if you don't have (or want) MX04 Professional or don't want to spend additional money on a service; and what if you prefer to build your own components and get a better understanding of
what's going on under the hood? Well, as long as you are happy to use progressive download you'll be glad to hear that this is all possible using: the NetConnection and NetStream classes, a video
object and the attachVideo() method of the Video class.
Bug Fixing
At the time of writing there are various problems with the Macromedia documentation, and patches are needed for this tutorial. Please note that these following URLs may be liable to change;
if so please search for the new files on macromedia.com using their search facility.
Download the file which is most relevant to you:
Windows:
flash_video_update.zip
Mac:
flash_video_update.dmg
Inside the zip/dmg file you will find the Flash_Video_Exporter.exe, MediaComponents.mxp and a readme file. If you don't have Flash MX04 Professional
then you don't need to concern yourself with the mxp file, as this is for the "Professional" version's components.
In accordance with the instructions in the readme file, go ahead and install the new video exporter.
Those with Flash MX04 Professional may also wish to resolve various bugs in the media player components, and this can be done using the mxp file,
but first you must ensure you have the latest version of Macromedia's extension manager, which can be found here:
http://www.macromedia.com/exchange/em_download/
|