Kind: global class
- VideoPlayer
- new VideoPlayer()
- .complete :
boolean
- .hasPlayed :
boolean
- .onComplete :
function
- .onFail :
function
- .onBuffer :
function
- .onProgress :
function
- .onReady :
function
- .container :
UIComponent
- .screen :
video
- .autoPlay :
boolean
- .currentTime :
number
- .duration :
number
- .paused :
boolean
- .percent :
number
- .source :
string
- .volume :
number
- .muted :
boolean
- .forceInline :
boolean
- .load()
- .play()
- .pause()
- .seek(sec)
- .stop()
- .mute()
- .unmute()
- .resize(width, height)
- .addCuePoint(time, handler, params)
- .addControls(obj)
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, })
A Boolean representing if the video has ended.
Kind: static property of VideoPlayer
A Boolean representing if the video has played to completion.
Kind: static property of VideoPlayer
A callback for when the Video is finished. Can be set as optional parameter on instantiated.
Kind: static property of VideoPlayer
A callback for when the Video fails. Can be set as optional parameter on instantiated.
Kind: static property of VideoPlayer
A callback for when the Video pauses due to buffering. Can be set as optional parameter on instantiated.
Kind: static property of VideoPlayer
A callback for when as Video progresses while playing. Can be set as optional parameter on instantiated.
Kind: static property of VideoPlayer
A callback for when Video is buffered and ready to play.
Kind: static property of VideoPlayer
A <div>, the top level container for the entire player instance.
Kind: static property of VideoPlayer
The <video> element, or if autoplay on a device, will return the driver object.
Kind: static property of VideoPlayer
A Boolean that changes if the video will automatically play.
Kind: static property of VideoPlayer
Example
myVideoPlayer.autoPlay = false;
A Number representing the video time position.
Kind: static property of VideoPlayer
A Number representing the length of the video in seconds.
Kind: static property of VideoPlayer
A Boolean representing if the video is playing.
Kind: static property of VideoPlayer
A Number 0-1 representing the video timeline percent position.
Kind: static property of VideoPlayer
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';
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;
A Boolean representing if the video volume is muted.
Kind: static property of VideoPlayer
A Boolean to force the video to play inline, NOTE: applies only to iphone iOS < 10
Kind: static property of VideoPlayer
Loads the current video source. If preload is true, this is redundant.
Kind: static method of VideoPlayer
Example
myPlayer.load()
Plays the current video.
Kind: static method of VideoPlayer
Example
myPlayer.play()
Pauses the current video.
Kind: static method of VideoPlayer
Example
myPlayer.pause()
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)
Stops the video and resets it to the beginning.
Kind: static method of VideoPlayer
Example
myPlayer.stop()
Mutes the Video Player, does not change the volume.
Kind: static method of VideoPlayer
Example
myVideoPlayer.mute()
Unmutes the Video Player, does not change the volume.
Kind: static method of VideoPlayer
Example
myVideoPlayer.unmute()
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)
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)
}
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
}
})