mercredi 26 mai 2010

Updated example keyboard input + Video streaming

The former example movie was not too complicated, but it didn't have a few possibilities which are needed for playing a video. We could load and play and replay the video in the FLVideoPlayback, but not really resume it.

To solve this problem we need a few extra "boxes", containers around the data. This is like the MovieClip around in image, or the Soundchannel around a sound.

First of all the new example: keyboard Input + Netstream Video

There are several examples of playing with images, sounds and video in this folder
we start with the keyboard input examples + netstreamvideo.fla

The first keys are the usual:
  • 1 for a sound
  • 2 for a stop sound
  • 3 for a image
  • 4 for a second image
Then we get to the playing of the video: (this part is new, but you practiced already this kind of scripting)
  • 5 playing the first video
  • 6 pausing the video
  • 7 resuming the video
  • 8 repositioning and rescaling the video
Then we have two keys left for the second video (the same for making the download zip smaller)
  • 9 load and play second video
  • 0 pause/resume second video
What about are the boxes? First we use a box called Netstream, which can be paused and resumed.
Then to get more than one video easily we made a special box called a class, starting from the examples from the FLASH Help, section NetStream.
This class must be included in the folder with the Flash movie. For the rest you can leave this alone. It has been imported at the top of the script:

import NetConnectionVideoClass;

In the script you can read what functions can be called, the name indicate what these functions are for.

To add a third video you have to do two things:
define the box:
var myVideoStream3:NetConnectionVideoClass=new NetConnectionVideoClass("MOV00948.flv");
where MOV00948.flv is the name (you can change, don't forget to put this new video also in the folder of the flash movie.)
and then copy and paste the play and resume parts, changing the name of course to myVideoStream3 instead of myVideoStream1 or myVideoStream2.

The other examples become more complex:
keyboard input start stop resume one button multiple video.fla starts pauses resumes a looping video on one button ( key 0)

If you want to use more than one video there is:
keyboard input start stop resume one button multiple video.fla
This movie has an array of video's, with positions etc, that play, pause, resume on one button.
For the sake of not going too much OO i have used the array and the playPauseResumeVideo function. Of course when more advanced you should make a nice new class.

(Yes the NetConnectionVideoClass.as is already a class....but one that can "just be used" )

Aucun commentaire:

Enregistrer un commentaire