-
Notifications
You must be signed in to change notification settings - Fork 5
Home
Butter API (v0.1)
Triggers an event with type name
. The event will be sent to each listener waiting for events of type name
, with options
as the only parameter.
Listen for an event with type name
. When an event occurs with type name
, handler
will be called. To receive data from the event, handler
should take one parameter in its signature.
Stop listening for events with type name
. If handler
is specified, all listeners for type name
will be forgotten. Otherwise, only the listener matching handler
will be effected.
Add trackEvent
to track
. track
may be a Track
object (see below), or a string, representing the name of a stored Track
. trackEvent
may be a TrackEvent
or an object representing the parameters to create a TrackEvent
(object parameters are passed directly to the TrackEvent
constructor). Returns a TrackEvent
if successful, and dispatches a "trackeventadded" event. Throws an error if track
is invalid, or no Media
is defined.
Returns an object whose properties are the names of stored Track
s. Each property references an array of TrackEvent
s belonging to the corresponding Track
.
Searches through track
for a TrackEvent
named name
, and returns it if successful. track
may be a Track
or a string representing the name of one.
Searches through track
for a TrackEvent
equivalent to or named by trackEvent
, and forgets it if successful. Upon removal, the corresponding TrackEvent
is returned, and a "trackeventremoved" event is dispatched.
Stores track
in the current Media
. If track
is and object with properties to create a Track
, it will be passed directly to the Track
constructor first, and the consequent Track
will be stored. Otherwise track
is assumed to be a valid Track
. The Track
object will be returned, and a "trackadded" event will be dispatched. Throws an error if no Media
is defined.
Returns an array of Track
s from the current Media
. Throws an error if no Media
is defined.
Searches for a Track
named name
and returns it if successful. Throws an error if no Media
is defined.
Searches for track
and removes it if successful. track
may be a string representing a named Track
, or the Track
object to be removed itself. Upon removal, the corresponding Track
is returned, and a "trackremoved" event is dispatched. Throws an error if no Media
is defined.
Stores target
. target
may be a Target
or an object with properties to create a Target
, in which case the object will be passed directly to the Target
constructor to create a Target
object to be stored instead. The Target
object is returned, and a "targetadded" event is dispatched.
Searches for target
, and removes it if successful. target
may be a Target
object, or a string representing the name of one. Upon removal, the corresponding Target
object is returned, and a "targetremoved" event is dispatched.
Returns an array of the currently stored Target
objects.
Searches for a Target
named name
and returns it if successful.
Plays the current Media
object.
Pauses the current Media
object.
Gets the current time of the current Media
object.
Returns an array containing all stored Media
objects.
Returns the currently selected Media
object.
Searches for a stored Media
object named name
, and returns it if successful.
Sets the current Media
to media
, which may be a Media
object, or a string representing the name of one. The referenced Media
object must be added first (see addMedia
below). Dispatches a "mediachanged" event if successful.
Stores media
, returns it, and dispatches a "mediaadded" event. media
is assumed to be a Media
object, or an object representing the properties to create one.
Searches for media
, and removes it if successful. media
may be a Media
object, or a string representing the name of one. Upon removal, the Media
object is returned, and a "mediaremoved" event is dispatched.
Attempts to return the location of the current butter.js
script.
Registers a Butter module, and extends the API to include methods from the module.
Extends the API. The Butter class and new instances of Butter objects will receive API additions.
Returns the name of the Track
.
Returns the internally-generated id of the Track
.
Searches for TrackEvent
named name
and returns it if successful.
Returns an array containing all TrackEvent
s stored in this Track
.
Searches for trackEvent
and removes it if successful. trackEvent
may be a TrackEvent
object, or a string representing the name of one.
Stores trackEvent
. trackEvent
may be a TrackEvent
object, or an object with properties for generating a TrackEvent
object, in which case the object will be sent directly to the TrackEvent
constructor.
Start time of the TrackEvent
.
End time of the TrackEvent
.
Type of the TrackEvent
Popcorn-specific options associated with the TrackEvent
.
The Popcorn track-event object associated with the TrackEvent
.
The Track
object to which the TrackEvent
is currently attached.
Returns the name of the TrackEvent
.
Returns the internally-generated id of the TrackEvent
.
The object the Target
represents. Most likely a DOM object.
Returns the name of the Target
object.
Returns the internally-generated id of the Target
object.
Stores mediaElement
to be represented by the Media
object.
Returns the media represented by the Media
object.
Returns the name of the Media
object.
Returns an array of Track
s stored in the Media
object.
Stores track
. If track
is and object with properties to create a Track
, it will be passed directly to the Track
constructor first, and the consequent Track
will be stored. Otherwise, track
is assumed to be a Track
object. The Track
object will be returned and a "trackadded" event will be dispatched.
Searches for a Track
named name
and returns it if successful.
Searches for track
and removes it if successful. track
may be a string representing a named Track
, or the Track
object to be removed itself. Upon removal, the corresponding Track
is returned, and a "trackremoved" event is dispatched.
Listen for an message with type type
. When a corresponding message is sent, callback
will be called. To receive data from the event, callback
should take one parameter in its signature.
Stop listening for events with type type
. If callback
is specified, all listeners for type type
will be forgotten. Otherwise, only the listener matching callback
will be effected.
Send an event with type type
. The message will be sent to each listener waiting for message of type type
. If type
is not specified, an attempt to use the general callback will occur.
Binds a Frame (likely an IFRAME), to channel name
. When the Frame has loaded, readyCallback
is called. When any message is received on this channel, messageCallback
is called.
Binds a Window to channel name
. When any message is received on this channel, callback
is called.
Listen for an message with type type
on channel name
. When a corresponding message is sent, callback
will be called. To receive data from the event, callback
should take one parameter in its signature.
Stop listening for events with type type
on channel name
. If callback
is specified, all listeners for type type
will be forgotten. Otherwise, only the listener matching callback
will be effected.
Send an event with type type
to channel name
. The message will be sent to each listener waiting for message of type type
. If type
is not specified, an attempt to use the general callback will occur.
Setup for the previewer module, passing in an options object containing mandatory parameters. Layout is a string pointing to the location of the layout that will be used within the previewer. Target specifies the DOM element in which the previewer should inhabit. Media is a string pointing to the location of the media object that will be used in Butter. Callback is a user specified function that will be executed after DOM scraping has completed.
returns a string that contains the popcorn code that has been created so far. The returned string has some styling applied to it.
Builds the version of popcorn that will be used within the previewer. VideoTarget is the id of the DOM element in which the video will be built. Popcorn is then built and ready to be populated with data. The previewer MUST be ready in order to build popcorn, so it is recommended that this be called in the callback of the previewer constructor/setup.