9. Okie dokie, remember those movie channels we wanted to subscribe to? Yeah, the ones that give 5 minute previews after midnight.
Let's request one:
var ns = new NetStream(nc);
Notice that we are passing in an argument of nc (the name of our NetConnection instance), because when we ask the cable company
for the channel we need to let them know which connection to send it down.
10. All we need to do now is make sure our TV is connected and able to receive the channel(s) we ordered. If your memory serves you well then you should remember
that way back in step two we created an instance of the Video object called videoContainer.
We're now going to use a method of that object. The method is called attachVideo() and we use it like this:
videoContainer.attachVideo(ns);
Again, you should note that we are passing in an argument (the name of our 'channel').
This basically hooks up the TV to the film channel. But there are so many films. Which one to watch?!
11. Finally, all that's left is to pick which movie we want. How about that old cult classic "Webby Does Dallas" … oh
sorry, I mean neil_pub.flv?
That's simple enough. We do it like this:
ns.play("neil_pub.flv");
Test It!
Now test your fla, and as long as you have an FLV file called neil_pub.flv in the same location as your
fla you should see the movie playing! If you see nothing then re-trace the steps in this tutorial and check you followed
each one correctly. If you still have no luck try re-encoding the original movie to FLV, or better still try using a
completely different Movie (or even the FLV I've included in the tutorial download file) incase there is an
incompatibility issue - the most important thing at this stage is to check that the code works.
Once the possibilities of code errors in Flash are resolved you can then turn your attention to anything else
that might be causing problems, but you can also get a little more feedback from Flash too…
Wait, There's More...
So far we've used one method of our NetStream object - play(), but there are a number of
methods and properties which can be used to track the progress of the file as it loads and plays,
and to give the user control over playback.
I will leave most of these for you to explore yourselves via the ActionScript dictionary (or perhaps for another tutorial later),
but we should at least look at getting more feedback using NetStreams one event handler - onStatus.
|