Subscribe to RSS
get email updates
home | about | pixDif AIR app | video tutorials
polyGeek.com

API support

video.Maru has it’s own site at videoMaru.com. The API documentation page has moved here.

polyGeek TV Learn how to use the video.Maru API to create a comboBox navigation.
polyGeek TV Use the video.Maru API to change the linkBTN text color when the btn is pressed.

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.

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.

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:

1
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:

1
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

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.

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.

New Additions ( video.Maru 3.0 only )

setMute(b:boolean):Void
Set the volume mute state: true/false.

setVideoComplete(fn:Function):Void
Set the callback function that is called when a video completes playing.

function 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.

function 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.

function 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.

function 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().

function 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.

function 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.
–>

If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.

Post to Twitter Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon


12 Comments »

12 Responses to “API support”


comment number 1 by: EricSalvi
June 27th, 2007 at 2:07 pm

Great job with that combo box component. Can all the same things be done and just use the List Component? Or even make your own text area with scroll bar?

comment number 2 by: polyGeek
June 27th, 2007 at 3:32 pm

@EricSalvi, You know what. All you have to do is open that API_comboBoxNav.fla file, drop a ListBox on the stage and give it an instance name of videoNav. Then take the instance name off of the comboBox and your set. Everything works just the same. Now you can have a scrollable list of videos to play.

I’m not sure how you would make a TextArea work for navigation. But I’m sure that the Tree, DataGrid, pretty much all the other navigation components should work. It’s just a matter of getting the change event and affecting video.Maru.

comment number 3 by: sam
July 26th, 2007 at 3:53 am

can you explain the use of ‘getCurrentFLV()’ a bit more and maybe give example usage. I think this could be used to help generate embed tag code, etc… but am unclear as to where this value ends up for usage once this function is called.

thanks

comment number 4 by: polyGeek
July 26th, 2007 at 8:12 am

@Sam, I added getCurrentFLV() so that if some were creating navigation outside of what video.Maru offers they would be able to get the filename of the current FLV and compare that to what the user selected. If the user selected FLV was the same as what is currently playing then you don’t want to reload and start playing the FLV. Basically, you do nothing.

comment number 5 by: mike wasiak
September 24th, 2007 at 10:58 am

Any idea whether it is possible to use a series of thumbnails for the video selections instead of a dropdown menu?

comment number 6 by: mike wasiak
September 24th, 2007 at 11:03 am

NM…hehe, figured it out

comment number 7 by: Barrie
October 24th, 2007 at 5:13 am

Sorry, just figured it out. I was using the beta version 3 SWC and not the updated ver 2 with the newly added setVideoComplete.

Cheers

comment number 8 by: Greg
October 25th, 2007 at 10:42 am

I’m no ActionScript guru so I was wondering how I could use the setVideoComplete callback to create a function that would send the playhead to another part of the score once the video has finished playing. I’m sure that it’s simpler than I think it is but I’m stumped. Thanks for the help.

comment number 9 by: polyGeek
October 25th, 2007 at 12:00 pm

@Greg, I’m not certain I understand what you want to do. If you would like to programmatically jump to a specific part of a video then you’re out of luck. The only options are the first or last frame of the video.

However, if you’re talking about controlling the playhead and going to a specific frame on a MovieClip then that’s pretty easy.

If you would like the videoWindow to display a specific image you could do that. video.Maru wouldn’t be of much help but you could load an image over the video.Window and then remove it again when the video plays.

comment number 10 by: Greg
October 25th, 2007 at 12:56 pm

I guess that what I want to do is detect when the FLV has finished playing and then “gotoAndPlay” another frame of the score.

I’m guessing that the setVideoComplete function would allow for that. I think that I’m just confused by what the “(fn:Function)” requires. I’m a novice on writing functions so the basic things still throw me. I’m sorry if that still does not make sense. Thanks for the feedback.

comment number 11 by: polyGeek
October 25th, 2007 at 6:22 pm

@Greg, you can do what you want to with no problems. Why don’t you watch the video at the top of this page about making a drop-down nav. That will give you the details on setting up the videoMaruCreationComplete function. Inside of there is where you will tell video.Maru which function to run when the video is complete.

You’re code will look something like this:

function videoMaruCreationComplete(maru:Object):Void {
setVideoComplete( videoComplete );
}

function videoComplete():Void {
this.gotoAndStop( someFrame/label );
}

comment number 12 by: video.Maru » Blog Archive » Fullscreen
November 30th, 2007 at 5:15 pm

[...] sure to read the video.Maru API page for more details about how to control FullScreen and change the layout of your design when [...]

   Welcome back (Change)

Leave a Reply

comment feed RSS   subscribe to this comment thread

Recent Posts

   



polyGeek.com

© Copyright 2008 polyGeek.com / Dan Florio, All Rights Reserved Except Where Explicitly Stated
Web Developement Blogs - Blog Catalog Blog Directory
M2 Websites
Local Directory for Los Angeles, CA

Better Tag Cloud