Skip to content

Latest commit

 

History

History
345 lines (272 loc) · 10.3 KB

VideoPlayer.md

File metadata and controls

345 lines (272 loc) · 10.3 KB

VideoPlayer

Kind: global class

new VideoPlayer()

This object creates a custom Video Player instance. This player has the ability to function as a regular player or it can work as the inline/autoplay video.

import { VideoPlayer } from 'ad-video'

Sample Player

View.main.videoPlayer = new VideoPlayer({
	source: adParams.videosPath + 'RED_Html5_Showcase_300x250.mp4',
	target: View.main,
	id: 'My_Unique_ID',
	css: {
		width: 300,
		height: 250
	},
	preload : false,
	autoPlay : false,
	muted : false,
	volume: .8,
	onComplete: function(event){
		console.log( 'video complete' )
	},
	onFail: global.failAd,
})

View.main.videoPlayer.play()



Sample Autoplay

View.main.videoPlayer = new VideoPlayer({
	source: [
		adParams.videosPath + 'RED_Html5_Showcase_300x250.mp4',
		adParams.videosPath + 'RED_Html5_Showcase_300x250.mpg'
	],
	target: View.main,
	id: 'My_Unique_ID',
	css: {
		width: 300,
		height: 250
	},
	preload : true,
	autoPlay : true,
	muted : true,
	forceInline : true,
	onComplete: function(event){
		console.log( 'video complete' )
	},
	onFail: global.failAd,
})

VideoPlayer.complete : boolean

A Boolean representing if the video has ended.

Kind: static property of VideoPlayer

VideoPlayer.hasPlayed : boolean

A Boolean representing if the video has played to completion.

Kind: static property of VideoPlayer

VideoPlayer.onComplete : function

A callback for when the Video is finished. Can be set as optional parameter on instantiated.

Kind: static property of VideoPlayer

VideoPlayer.onFail : function

A callback for when the Video fails. Can be set as optional parameter on instantiated.

Kind: static property of VideoPlayer

VideoPlayer.onBuffer : function

A callback for when the Video pauses due to buffering. Can be set as optional parameter on instantiated.

Kind: static property of VideoPlayer

VideoPlayer.onProgress : function

A callback for when as Video progresses while playing. Can be set as optional parameter on instantiated.

Kind: static property of VideoPlayer

VideoPlayer.onReady : function

A callback for when Video is buffered and ready to play.

Kind: static property of VideoPlayer

VideoPlayer.container : UIComponent

A <div>, the top level container for the entire player instance.

Kind: static property of VideoPlayer

VideoPlayer.screen : video

The <video> element, or if autoplay on a device, will return the driver object.

Kind: static property of VideoPlayer

VideoPlayer.autoPlay : boolean

A Boolean that changes if the video will automatically play.

Kind: static property of VideoPlayer
Example

myVideoPlayer.autoPlay = false;

VideoPlayer.currentTime : number

A Number representing the video time position.

Kind: static property of VideoPlayer

VideoPlayer.duration : number

A Number representing the length of the video in seconds.

Kind: static property of VideoPlayer

VideoPlayer.paused : boolean

A Boolean representing if the video is playing.

Kind: static property of VideoPlayer

VideoPlayer.percent : number

A Number 0-1 representing the video timeline percent position.

Kind: static property of VideoPlayer

VideoPlayer.source : string

Changes the source of the video. Pass a string of the video file path to set.

Kind: static property of VideoPlayer
Example

myVideoPlayer.source = 'videos/myVideoFile.mp4';

VideoPlayer.volume : number

Changes the volume of the video. Assign a number, between 0 - 1 to set the volume.

Kind: static property of VideoPlayer
Example

myVideoPlayer.volume = .8;

VideoPlayer.muted : boolean

A Boolean representing if the video volume is muted.

Kind: static property of VideoPlayer

VideoPlayer.forceInline : boolean

A Boolean to force the video to play inline, NOTE: applies only to iphone iOS < 10

Kind: static property of VideoPlayer

VideoPlayer.load()

Loads the current video source. If preload is true, this is redundant.

Kind: static method of VideoPlayer
Example

myPlayer.load()

VideoPlayer.play()

Plays the current video.

Kind: static method of VideoPlayer
Example

myPlayer.play()

VideoPlayer.pause()

Pauses the current video.

Kind: static method of VideoPlayer
Example

myPlayer.pause()

VideoPlayer.seek(sec)

Skips the video to a specific time.

Kind: static method of VideoPlayer

Param Type Description
sec number The time to skip the video to in seconds.

Example

myPlayer.seek(4)

VideoPlayer.stop()

Stops the video and resets it to the beginning.

Kind: static method of VideoPlayer
Example

myPlayer.stop()

VideoPlayer.mute()

Mutes the Video Player, does not change the volume.

Kind: static method of VideoPlayer
Example

myVideoPlayer.mute()

VideoPlayer.unmute()

Unmutes the Video Player, does not change the volume.

Kind: static method of VideoPlayer
Example

myVideoPlayer.unmute()

VideoPlayer.resize(width, height)

Changes the size of the Video Player

Kind: static method of VideoPlayer

Param Type Description
width number A number of the width
height number A number of the height

Example

myVideoPlayer.resize(400, 300)

VideoPlayer.addCuePoint(time, handler, params)

Add to the load queue: a single or array of files or even another Loader.

Kind: static method of VideoPlayer

Param Type Description
time number The time, in seconds, to fire the call back.
handler function A callback function.
params object Optional parameters to pass back through the call back.

Example

myVideoPlayer.addCuePoint(3, handleCuePoint, [true, .3, {}])

function handleCuePoint(isVar, num, obj) {
	console.log('cue point', isVar, num, obj)
}

VideoPlayer.addControls(obj)

Adds VideoControls to the VideoPlayer instance. Used only if controls NOT passed thru on instantiation.

Kind: static method of VideoPlayer

Param Type Description
obj object An object of desired controls, see VideoControls

Example

myVideoPlayer.addControls({
	controlBar : {
		buttonPlayPause : true,
		progressControl : true,
		buttonFullScreen : true
	}
})