-
Notifications
You must be signed in to change notification settings - Fork 5
src.core.popcorn wrapper
#PopcornWrapper (Module)
Provides Popcorn-wrapping functionality to Butter.
Usage:
var PopcornWrapper = require('path/to/module/popcorn-wrapper.js');
##PopcornWrapper::currentTime (read-write Property)
Wraps Popcorn's currentTime controls. On operational when media is ready and Popcorn is initialized.
@return [ Number ]
##PopcornWrapper::duration (read-only Property)
Duration of Popcorn media.
@return [ Number ]
##PopcornWrapper::muted (read-write Property)
Wraps Popcorn's muted controls.
@return [ Boolean ]
##PopcornWrapper::paused (read-write Property)
Wraps Popcorn's pause controls. Reports true when Popcorn is not initialized.
@return [ Boolean ]
##PopcornWrapper::popcorn (read-only Property)
Reference to Popcorn instance.
@return [ Popcorn ]
##PopcornWrapper::volume (read-write Property)
Wraps Popcorn's volume controls.
@return [ Boolean ]
##PopcornWrapper::addPopcornHandlers (public Member Function)
Setup any handlers that were defined in the options passed into popcorn wrapper. e.g. timeupdate, paused, etc.
Usage:
addPopcornHandlers();
##PopcornWrapper::checkTimeoutLoop (private Member Function)
Abstracts the problem of waiting for some condition to occur with a timeout. Loops on checkFunction, calling readyCallback when it succeeds, or calls timeoutCallback after timeoutDuration milliseconds.
- checkFunction [ Function ]: Function used to check if waiting to continue.
- readyCallback [ Function ]: Function to call when conditions are met.
- timeoutCallback [ Function ]: Function to call after time has expired.
- timeoutDuration [ Number ]: Amount of time to wait before aborting and calling timeoutCallback.
Usage:
checkTimeoutLoop(checkFunction, readyCallback, timeoutCallback, timeoutDuration);
##PopcornWrapper::clear (public Member Function)
Wipes the current Popcorn instance and anything it created.
- container [ String or DOMElement ]: Element (or an id of one) to clear.
Usage:
p.clear(container);
##PopcornWrapper::constructPlayer (private Member Function)
If possible and necessary, reformats the dom to conform to the url type specified for the media. For example, youtube/vimeo players like
- target [ String ]: Id of the target element to prepare.
Usage:
constructPlayer(target);
##PopcornWrapper::createPopcorn (private Member Function)
Creates a Popcorn instance in the page. Tries running the generated function first (from popcornString) and inserts it as a script in the head if that fails.
- popcornString [ String ]: String to convert into a Function.
Usage:
createPopcorn(popcornString);
##PopcornWrapper::destroyEvent (public Member Function)
Destroys a Popcorn trackevent.
- trackEvent [ TrackEvent ]: Butter TrackEvent referencing the desired Popcorn event.
Usage:
p.destroyEvent(trackEvent);
##PopcornWrapper::findMediaType (private Member Function)
Determines the type of media that is going to be used based on the specified url.
- url [ String ]: URL to use as a basis for deriving a media type.
Usage:
findMediaType(url);
##PopcornWrapper::getSoundCloudQuarantine (private Member Function)
XXX: SoundCloud has a bug (reported by us, but as yet unfixed) which blocks loading of a second iframe/player if the iframe for the first is removed from the DOM. We can simply move old ones to a quarantine div, hidden from the user for now (see #2630). We lazily create and memoize the instance.
Usage:
getSoundCloudQuarantine();
##PopcornWrapper::interruptLoad (public Member Function)
Cancel loading or preparing of media whilst attempting to setup.
Usage:
p.interruptLoad();
##PopcornWrapper::pause (public Member Function)
Passthrough to Popcorn's pause method.
- readyCallback [ Function ]: Function to call when media is ready.
- timeoutCallback [ Function ]: Function to call after timeout occurs.
Usage:
p.pause();
##PopcornWrapper::play (public Member Function)
Passthrough to Popcorn's play method.
- readyCallback [ Function ]: Function to call when media is ready.
- timeoutCallback [ Function ]: Function to call after timeout occurs.
Usage:
p.play();
##PopcornWrapper::prepare (public Member Function)
Creates functions for various failure and success cases, generates the Popcorn string, and ensures our player is ready before actually creating the Popcorn instance and notifying the user.
- url [ String ]: URL for media to be passed to Popcorn.
- target [ String ]: Target for Popcorn media.
- popcornOptions [ Dictionary ]: Other Popcorn options.
- callbacks [ Dictionary ]: Callback functions to call at various times during string generation.
- scripts [ Dictionary ]: Scripts to run at various times during string generation.
Usage:
p.prepare(url, target, popcornOptions, callbacks, scripts);
##PopcornWrapper::unbind (public Member Function)
Destroy popcorn bindings without touching other discovered settings.
Usage:
p.unbind();
##PopcornWrapper::updateEvent (public Member Function)
Updates a Popcorn event with data from a Butter TrackEvent.
- trackEvent [ TrackEvent ]: Butter TrackEvent containing data to pass through to a Popcorn event.
Usage:
p.updateEvent(trackEvent);
##PopcornWrapper::waitForMedia (private Member Function)
Waits for the media to return a sane readyState and duration so Butter can interact with it (uses checkTimeoutLoop).
- readyCallback [ Function ]: Function to call when media is ready.
- timeoutCallback [ Function ]: Function to call after timeout occurs.
Usage:
waitForMedia(readyCallback, timeoutCallback);
##PopcornWrapper::waitForPopcorn (private Member Function)
Waits for Popcorn and required players load to be initialized (uses checkTimeoutLoop).
- readyCallback [ Function ]: Function to call when media is ready.
- timeoutCallback [ Function ]: Function to call after timeout occurs.
Usage:
waitForPopcorn(readyCallback, timeoutCallback);