In this section, you will learn how to use KWIK Player's functions!
Start media playback
kwikMotion('player').play();
Pause media playback
kwikMotion('player').pause();
Check if the player is paused
//Get whether the player is paused or not
var isPaused = kwikMotion('player').paused();
//If the player is paused, then play. Else, pause
if (isPaused)
kwikMotion('player').play();
else
kwikMotion('player').pause();
Returns true if the video has ended, false otherwise.
//Check ended state
var endedState = kwikMotion('player').ended();
Returns true if the player is in the "seeking" state, false otherwise.
//Get seeking state
var isInSeeking = kwikMotion('player').seeking();
Returns the TimeRanges of the media that are currently available for seeking to.
//Seekable function
var timeRangeSeekable = kwikMotion('player').seekable();
Gets or Sets the current playback rate. A playbakc of 1.0 repsents normal speed.
The higher value you set, the faster playback you get.
The lower value you set, the slower playback you get.
//Get current playback rate
var currentPlaybackRate = kwikMotion('player').playbackRate();
//Set playback rate to half for instance
kwikMotion('player').playbackRate(0.5);
Name | Type | Required | Description |
---|---|---|---|
Rate | Number | Yes | New playback rate value to set |
Get the length in time of the video in seconds
//Get the duration of the video played
var lengthOfVideo = kwikMotion('player').duration();
Note
The video must have started loading before the duration can be known, and in the case of Flash, may not be known until the video starts playing.
Name | Type | Required | Description |
---|---|---|---|
seconds | Number | Yes | Duration when setting |
Get or set the current time (in seconds)
//Get currentTime
var whereYouAt = kwikMotion('player').currentTime();
Name | Type | Required | Description |
---|---|---|---|
seconds | Number|String | Yes | The time to seek to |
Get the time left (in seconds)
//Get time left
var timeRemaining = kwikMotion('player').remainingTime();
Get/Set the loop attribute of the video element
//Get loop value
var loopValue = kwikMotion('player').loop();
//Activate loop
kwikMotion('player').loop(true);
//Deactivate loop
kwikMotion('player').loop(false);
Name | Type | Required | Description |
---|---|---|---|
value | Boolean | Yes | True|False to determine whether the video should loop or no |
Get a TimeRange object with the times of the video that have been downloaded.
If you just want the percent of the video that's been downloaded, use bufferedPercent.
// Number of different ranges of time have been buffered. Usually 1.
var numberOfRanges = bufferedTimeRange.length;
// Time in seconds when the first range starts. Usually 0.
var firstRangeStart = bufferedTimeRange.start(0);
// Time in seconds when the first range ends
var firstRangeEnd = bufferedTimeRange.end(0);
// Length in seconds of the first time range
var firstRangeLength = firstRangeEnd - firstRangeStart;
Returns the ending time of the last buffered time range.
//Get ending time
var endTime = kwikMotion('player').bufferedEnd();
Get the percent (as a decimal) of the video that's been downloaded.
//Get percent
var percentDownloaded = kwikMotion('player').bufferedPercent();
Destroys the KWIK motion player and does any necessary cleanup
kwikMotion('player').dispose();
Get the current type of the player
//Get the current type of the player
var currentType = kwikMotion('player').currentType();
Set or get the current MediaError
//Get the current MediaError
var currentError = kwikMotion('player').error();
//Set the current MediError
kwikMotion('player').error(parameter goes here);
Name | Type | Required | Description |
---|---|---|---|
err | * | Yes | A MediaError or a String/Number to be turned into a MediaError |
Get object for cached values.
//Get cache
var cache = kwikMotion('player').getCache();
Get or Set the source of the video played
//Get the source
var vidSource = kwikMotion('player').src();
//Set the source to a newSource
kwikMotion('player').src(newSource);
Name | Type | Required | Description |
---|---|---|---|
source | String|Object|Array | Yes | The source URL, object, or array of sources |
Get or set the current volume of the media
//This is how to get the current volume:
var howLoudIsIt = kwikMotion('player').volume();
//This is how to set the volume:
kwikMotion('player').volume(0.5); // Set volume to half
0 is off (muted), 1.0 is all the way up, 0.5 is half way.
Name | Type | Required | Description |
---|---|---|---|
percentAsDecimal | Number | Yes | The new volume as a decimal percent |
Set the player to be in full screen mode
//This is how to set the player to be in full screen mode:
kwikMotion('player').requestFullscreen();
Exit the full screen mode
//This is how to set the player to exit the full screen mode:
kwikMotion('player').exitFullscreen();
Get or set whether or not the controls are showing.
//This is how to get whether or not the controls are showing:
var controlsShow = kwikMotion('player').controls();
//This is how to set the controls to be shown:
kwikMotion('player').controls(true);
//This is how to set the controls to be hidden:
kwikMotion('player').controls(false);
Name | Type | Required | Description |
---|---|---|---|
bool | Boolean | Yes | Set controls to showing or not |
Get the current muted state, or turn mute on or off
//This is how to get whether or not the volume is muted:
var isVolumeMuted = kwikMotion('player').muted();
//This is how to set the volume to be muted:
kwikMotion('player').muted(true);
Name | Type | Required | Description |
---|---|---|---|
muted | Boolean | No | True to mute, false to unmute |
Get/Set the aspect ratio of the player
//Get the aspect ratio of the player
var playerAspectRatio = kwikMotion('player').aspectRatio();
//Set the aspect ratio of the player to 16:9
kwikMotion('player').aspectRatio("16:9");
Name | Type | Required | Description |
---|---|---|---|
ratio | String | No | Defines the aspect ratio of the player |
Get/Set the autoplay attribute
//Get the current autoplay attribute value
var currentAutoPlay = kwikMotion('player').autoPlay();
//Set the autoplay attribute to true
kwikMotion('player').autoPlay(true);
//Set the autoplay attribute to flase
kwikMotion('player').autoPlay(false);
Name | Type | Required | Description |
---|---|---|---|
value | Boolean | Yes | Boolean to determine if the video should autoplay |
When fullscreen isn't supported we can stretch the video container to as wide as the browser will let us.
kwikMotion('player').enterFullWindow();
Exit the full window mode
//This is how to set the player to exit the full screen mode:
kwikMotion('player').exitFullscreen();
Get the current source of the video played
//Get the current source
var vidSource = kwikMotion('player').currentSrc();
Returns the current state of network activity for the element, from the codes in the list below.
//Get network state
var netState = kwikMotion('player').networkState();
Returns/Set the player height.
//Get height
var playerHeight = kwikMotion('player').height();
//Set height
kwikMotion('player').height(newHeightValue);
Name | Type | Required | Description |
---|---|---|---|
Value | Number | No | Value for new height |
Returns/Set the player width.
//Get width
var playerWidth = kwikMotion('player').width();
//Set width
kwikMotion('player').width(newWidthValue);
Name | Type | Required | Description |
---|---|---|---|
Value | Number | No | Value for new width |
Get/Set dimension of the player.
//Get dimension(width)
var playerWidth = kwikMotion('player').dimension('width');
//Get dimension(height)
var playerWidth = kwikMotion('player').dimension('height');
//Set dimension(width)
kwikMotion('player').dimension('width', newWidthValue);
//Set dimension(height)
kwikMotion('player').dimension('height', newWidthValue);
Name | Type | Required | Description |
---|---|---|---|
Dimension | String | Yes | width|height |
Value | Number | No | Value of the new dimension (when setting) |
Begin loading the src data.
//Load the src data
kwikMotion('player').load();
Get/Set the poster image source url.
//Get the poster image
var posterImg = kwikMotion('player').poster();
//Set the poster image
kwikMotion('player').poster(sourceOfTheNewPoster);
Name | Type | Required | Description |
---|---|---|---|
src | String | No | Poster image source URL |
Note
In order to see how the Set Poster button works, click it before start playing the video!
Get/Set the preload attribute value.
//Get the preload attribute value
var preloadValue = kwikMotion('player').preload();
//Set the preload attribute value
kwikMotion('player').preload(newpreloadValue);
Name | Type | Required | Description |
---|---|---|---|
value | String | Yes | auto|metadata|none |
Returns a value that expsses the current state of the element with respect to rendering the current playback position, from the codes in the list below.
//Check ready state
var isReady = kwikMotion('player').readyState();
Check if the full screen is supported
var isFullScSupported = kwikMotion('player').supportsFullScreen();
Get/Set if the user is active
//Get user active
var isUserActive = kwikMotion('player').userActive();
//Set user active
kwikMotion('player').userActive(newValue);
Name | Type | Required | Description |
---|---|---|---|
bool | Boolean | Yes | New value when setting |
Get video width
//Get video width
var videoWidth = kwikMotion('player').videoWidth();
Get video height
//Get video height
var videoHeight = kwikMotion('player').videoHeight();
Returns a reference to the current tech.It will only return a reference to the tech if given an object with the IWillNotUseThisInPlugins property on it. This is try and pvent misuse of techs by plugins.
//Get reference to tech
var tech = kwikMotion('player').tech();
Check if the player is in fullscreen mode.
//Check full screen mode
var isFullScreen = kwikMotion('player').isFullscreen();
Add/Remove the fluid class.
//Add fluid class
kwikMotion('player').fluid(true);
//Remove fluid class
kwikMotion('player').fluid(false);
Name | Type | Required | Description |
---|---|---|---|
bool | Boolean | Yes | True to add fluid, false to remove |
Add a remote text track.
//Add remote text track
kwikMotion('player').addRemoteTextTrack(optionsToAdd);
Name | Type | Required | Description |
---|---|---|---|
options | Object | Yes | Options for remote text track |
Add a text track.
In addition to the W3C settings, we allow adding additional info through options.
//Add a text track
kwikMotion('player').addRemoteTextTrack(optionsToAdd);
Name | Type | Required | Description |
---|---|---|---|
kind | String | Yes | Captions, subtitles, chapters, descriptions, or metadata |
label | String | No | Optional label |
options | Object | Yes | Optional language |
Get an array of remote html track elements.
//Get track elements
var trackEls = kwikMotion('player').remoteTextTrackEls();
Get an array of remote text tracks
//Get tracks
var tracks = kwikMotion('player').remoteTextTracks();
Remove a remote text track
//Remove remote text track
kwikMotion('player').removeRemoteTextTrack(trackObjectToBeRemoved);
Name | Type | Required | Description |
---|---|---|---|
track | Object | Yes | Remote text track to remove |
Get an array of associated text tracks.
//Get text tracks
kwikMotion('player').textTracks();
Get the player's language dictionary.
//Get player language
var lang = kwikMotion('player').language();
Note
The language should be set in the player options if you want the the controls to be built with a specific language. Changing the lanugage later will not update controls text.
Name | Type | Required | Description |
---|---|---|---|
code | String | Yes | Language to be used |
Get the player language dictionary.
//Get languages
var lang = kwikMotion('player').languages();
Returns whether or not the user is scrubbing. Scrubbing is when the user has clicked the progress bar handle and is dragging it along the progress bar.
//Scrubbing
var isScrubbing = kwikMotion('player').scrubbing();
Name | Type | Required | Description |
---|---|---|---|
isScrubbing | Boolean | Yes | Ture|False |