Important: when accessing the video.Maru API you are targeting the SWC that you have placed in your FLA. You do not need to give the SWC an instance name because it does that for itself. That instance name is videoMaru.
The cornerstone to the video.Maru API is the videoMaruCreationComplete function. That is a function that you write and video.Maru will call that function for you when it has finished setting up the video interface.
The videoMaruCreationComplete function is where you’ll place code that is there to set or override certain properties of video.Maru. If for instance you wanted to change the size of the videoWindow on startup to reflect the dimensions reported by the FLV metaData then you’ll have to wait until the video.Maru code gets far enough that it knows what the videoWindow is. You can see a code sample of this below under getVideoMetaHeight.
It’s a good practice to place your videoMaruCreationComplete function on the same layer as the video.Maru SWC.
closeNetstream() ( beta )
Closing the Netstream object halts the download of the video stream and stops playback. When you click on a videoLink it will create a new Netstream and begin playback.
formatTime( s:String ):String
Takes a String that indicates a duration of time and returns a properly formated hour:minute:second display. Note: the reason it takes a String and not a Number is that the video metaData returns a String for the duration. Example: if you pass formatTime( 125 ) it will return 2:05.
getCurrentFLV():String
If you need to know what the current path/fileName.flv then use this. It would be handy if for instance you wanted to give someone the option to download the FLV to their system.
getIsPlaying():Boolean
Returns a true/false regarding the current state of playback. Usage: you might use this in an onEnterFrame if you want to track the current state of the playback so that when the video is not playing you could do something bandwidth intensive.
getLinkButtonArray():Array
Returns an array of all the linkBTNs corresponding to the videos listed in an XML file. Usage: you can loop through the array and add a number to the beginning of each linkBTN.link TextField. Or you could use it to change the appearance of a linkBTN after the user has played that video.
getVideoMetaHeight():Number
Returns the height of the video that is currently playing as reported by the metaData in the FLV. You cannot depend on this value being available in all cases. The Flash video encoder does add this metaData but not all encoders do. For instance the youTube videos that I have checked do not report the width/height in the metaData.
The code sample below will resize the videoWindow to fit the actual size of the FLV each time the video changes. If there is no width/height embedded in the metaData then it defaults to 320×240.
Note: there is a bit of a delay from the video starting to the resize. That’s caused by the delay in the Flash player reading the metaData. I don’t know of anything that can be done about that. Other than including the width/height in your XML file and getting the data from that. But that’s another project.
playVideo(s:String):Void
Send a path/filename.flv to this function and it will play that FLV, if it can be loaded.
setFadeTrayDuration(n:Number):Void
The fadeTray takes 1.5 seconds to fade in and out. If you would like to change that then pass in the number of seconds you would like to change it to. As an example if you wanted it to take 3 seconds to fade in and out then use this:
video.Maru.setFadeTrayDuration(3);
setFullScreenCallback(fn:Function):Void
description
setIsPlaying(b:Boolean):Void
You can bypass the play_btn/pause_btn with your own control by calling this function and passing the state of isPlaying. To pause the video call:
videoMaru.setIsPlaying(false);
This is especially useful if you want to have two separate buttons for the play and the pause. With the video.Maru interface that is not possible. You’ll have to create a button for each state - but don’t give them instance names of play_btn or pause_btn.
Here is some sample code for two buttons placed on the same layer as the video.Maru SWC
setLinkBtnPressed( fn:Function ):Void
Get notified when the user clicks on a linkBTN. Usage: you could use this to change the state of the button when pressed and then switch it back when released with setLinkBtnReleased().
setLinkBtnReleased( fn:Function ):Void
Get notified when the user clicks and releases on a linkBTN. Usage: you could use this to change the state of the button when pressed with setLinkBtnPressed() and then switch it back when released.
setMetaDataChangedCallback(fn:Function):Void
When the Flash player detects a change in the FLV metaData this function that you specify will be called. You can see an example of this under getVideoMetaHeight() above.
setMute(b:boolean):Void
Set the volume mute state: true/false.
setOnCuePoint( fn:Function ):Void
Set the callback function that is called when a cue point in your video is reached. You can read more about it here. Download the example.
setOnVideoComplete(fn:Function):Void
Set the callback function that is called when a video completes playing. See example.
setSmoothing(b:Boolean):Boolean
Turn smoothing on or off. Smoothing determines whether the video should be smoothed (interpolated) when it is scaled. For smoothing to work, the player must be in high-quality mode. The default value is false (no smoothing).
setVideoChangeCallback(fn:Function):Void
If set calls the function you specify when the FLV playing in the videoWindow is changed.
setVideoWindowHeight(n:Number):Void
Change the height of the videoWindow. See getVideoMetaHeight() above for an example.
setVideoWindowWidth(n:Number):Void
Change the width of the videoWindow. See getVideoMetaHeight() above for an example.
setVideoWindowX(n:Number):Void
Change the _x value of the videoWindow.
setVideoWindowY(n:Number):Void
Change the _y value of the videoWindow.
setXmlCallback(fn:Function):Void
Set a function to be called when the XML has been parsed into an object. The callback that you set needs to accept an argument of type Object. See below for an example.
toggleFullScreenVideo():Void
Toggles the fullScreen between fullScreen and in-browser views.
togglePlayPause():Void
Toggles the video playback between paused and playing. It will also change the state of your play_btn/pause_btn if available.