Player Class
This is for Player operations. It depends to Device. Some methods are abstracted by Devices
Index
Methods
- Player constructor
- addAdsCaption
- addVideoSource
- checkAdsStatus
- createOIPFDrmAgent
- createVideoElement
- deleteVideoElement
- initAds
- initAudioClass
- initAudioClass
- initVastAd
- pause
- play
- playWithLoop
- prepareVastFromVmap
- readVastFile
- registerVideoEvents
- restart
- seekToTime
- seekWithTimeAdd
- sendWebOSDrm
- setPlayerInfo
- setupWebOSDrm
- stop
- togglePlay
- unloadDrmClient
Constructor
Player
(
-
currentDevice
-
events
-
config
)
-
currentDevice -
events -
config
Parameters:
-
currentDeviceObject- Current device object
-
eventsObject- Events class inheritance
-
configObject- Config object
Methods
addAdsCaption
()
Boolean
Adds ads caption to video player to end user notified about Ads This text can be edited via config
Returns:
addVideoSource
(
-
src
-
customData
)
-
src -
customData
Adds video source to element. If trying to play DRM video you have to send customData with video source It sets this customData to player info so it can be accessible. Checks content address if it includes manifest regex it will start DRM functions automatically It catches DRM providers with currentDevice You can send HLS, Live HLS and Microsoft SS (PlayReady) content TODO DRM providers can be included in another function
Parameters:
-
srcString- Source url for video content
-
customDataString- Custom Data
checkAdsStatus
()
This function is triggered with timeUpdate event of video player. It compares with Vast time with current time
createOIPFDrmAgent
()
Drm initiator for OIPF Devices such as Vestel and Arcelik
createVideoElement
()
Creates Video element. It creates a HTML5 video element with config videoPlayerId Then you can reach this video element with this.videoElement It appends this video element to body. You have to set it to a fixed position with css. Most of Tv manufacturers runs its own video player and its position fixed to (0,0) cooridnates Its important to consider your design
Returns:
null
deleteVideoElement
()
Boolean
Removes videoElement from DOM. Its recommended to call this function if you are consider to close video TODO We have to check DRM inited if yes we have to detach DRM before removing
Returns:
initAds
(
-
type
-
url
)
-
type -
url
Initialize ads with given source and type. So type is mandatory field to operate
Parameters:
-
typeString- Type of ads source 'VMAP' or just 'VAST'
-
urlObject- Url of ads source VMAP or VAST Url
Returns:
initAudioClass
()
Constructor for Audio class
initAudioClass
()
Add Subtitle Method
initVastAd
(
-
time
)
-
time
It starts ads in videoPlayer. Pauses current video then starting ads After completing ads it starts old src url with initial seeking with time
Parameters:
-
timeObject- current time of video player
pause
()
Pause trigger for videoElement
play
()
Play trigger for videoElement
playWithLoop
()
Play trigger for a video element with endless autoloop you can use this feature to enable silent background videos
prepareVastFromVmap
(
-
vmapObject
)
-
vmapObject
If ads type is VMAP and detected in initAds method it will call automatically this function
Parameters:
-
vmapObjectObject- Vmap object its response of VMAP XML
readVastFile
(
-
vastUrl
-
options
)
-
vastUrl -
options
Reads Vast file and seperates its source and options (extensions, type etc)
Parameters:
-
vastUrlString- URL address for Vast
-
optionsObject- It stands for this.config.vastOptions
Returns:
}
registerVideoEvents
()
Trigger specific events for all videoElement trigger
restart
()
Sets currentTime to 0 and plays automatically
seekToTime
(
-
value
)
-
value
Seek to given time TODO Check device performances if needed use pause method first
Parameters:
-
valueObject
seekWithTimeAdd
(
-
value
)
-
value
Seek with given value adding
Parameters:
-
valueNumber
sendWebOSDrm
()
WebOs Drm trigger
setPlayerInfo
()
Object
Sets this.playerInfo with initial values. This values usefull for later usages For example Vast, device specific, DRM Type etc we are using this object
Returns:
this.playerInfo
setupWebOSDrm
()
Initialize WebOs DRM TODO This can be move to webos device with abstract
stop
()
Stop trigger for videoElement it removes video element from dom
togglePlay
()
Play/Pause toggle trigger for videoElement
unloadDrmClient
()
Unloads DRM client. !IMPORTANT! Some devices may be crash if you are not unloaded drm client