Tuesday, July 29, 2008

VideoViewer Class (AS3)

The VideoViewer Class is a class I created to quickly put together a video player in a matter of minutes. This is just part of a package that includes other classes such as the ProgressionBar Class which controls the scrubber and the time line. I will release the other classes at a later date.


The VideoViewer class has an easy to use API , that only consists of a couple methods and properties.



Methods

VideoViewer.readyVideo();

This sets up the video to be played. This method MUST be called for the class to work. Without calling this method, the video wil never get loaded into the viewer.

VideoViewer.toggleVideo();

This toggles the pause and play states of the video. This is needed to start the video after the readyVideo() method is called. It can be place in play button functions or right after the readyVideo() method to start the video automatically.

VideoViewer.stopVideo();

This closes the video connection and stops the video. Once this is called, to play the video again, You need to recall the readyVideo() method.

VideoViewer.seeker(value:Number);

This allows you to jump to different points in the video. This method allows one parameter. This parameter is the number (in seconds) you want the play head of the video to jump to.


Properties

VideoViewer.ns;

Returns the NetStream Object inside the VideoViewer.

VideoViewer.file;

Sets the what video to play as a String //Ex: VideoViewer.file = "myVIdeo.flv";
Also returns what video is currently set.

VideoViewer.buffer;

Sets the buffer amount in seconds.


Instantiation

Change the Linkage of a MovieClip to VideoViewer ----- com.clementegomez.video.VideoViewer.
Be sure to make it the base class if you plan to have more than one VideoViewer in your scene.

Helper Events

Along with the methods and properties included with the VideoViewer API. There are also events that keep track of certain data.

VVInfoEvent.STATS

This will allow you to keep track of some information dealing with the VideoViewer instance.

DurationEvent.DURATION

This keeps track of the duration of the video being played.


Here is an example of how to easily set up the VideoViewer.


import com.clementegomez.video.VideoViewer;
import flash.display.Sprite;

viewer.file = "myVideoflv";
viewer.readyVideo();
viewer.toggleVideo();


viewer in the above example is a VideoViewer Instance.


Known Bugs:
1) Scaling the VideoViewer will distort the video that it is playing. A workaround is to set the size of the shape inside the Movieclip or to set the height and width of the Video Viewer manually. Ex:


VideoViewer.height = 100;
VideoViewer.width = 100;


This is a very useful class and I hope you put it to good use. If there are any questions at all please post them here and I will try to answer them in a timely manner.

Enjoy

Download VideoViewer Class Here

3 comments:

  1. [...] finally released the kreativeKING Videoplayer API. I’m sure you all remember the old VideoViewer and ProgressionBar classes. Well this new set of API does away with those and replaces with a [...]

    ReplyDelete
  2. Im looking to buy it.... but is it hard for me to modify so i can call the play and pause functions from a html link using javascript?

    Im not a programmer, now just a little as1.

    Would be extremly glad if you could answer this before i purchase it.

    ReplyDelete
  3. Well the VideoViewer Class is depricated for the new and improved VideoWindow Class. Yes the VideoWindow Class is very easy to use. If you are looking to setup a Javascript function to trigger an AS3 function. You'll have to setup a ExternalInterface for it to work. You're in Luck though as i created an example on using the ExternalInterface Class not too long ago. Check it out here

    http://blog.kreativeking.com/2009/02/javascript-and-actionscript-conversation/

    ReplyDelete