Analytics
Events
You can get various player states from the app by setting the on function.
class ViewController : UIViewController {
let vpplayer: VPPlayer = VPPlayer()
override func viewDidLoad ()
{
vpplayer.on { (event, args) in
// Example
if VPPlayerEvent.loaded == event {
print(event)
}
}
}
}
PlayerState Types and Return Value
| PlayerState | Description | Value Return Type |
|---|---|---|
| play | User clicked play button | Bool |
| paused | Video is paused | Bool |
| timeupdate | Notifies each second of current video playing | CMTime |
| canplay | Can play or not Video | Bool |
| ended | Video has ended | Bool |
| replay | Video is replayed | Bool |
| rewind | User clicked rewind button | Int |
| forward | User clicked forward button | Int |
| seeking | User seeking with slider | Double |
| seekStarted | Position were seeking with slider started | Double |
| seekEnded | Position were seeking with slider ended | Double |
| mute | Video is muted | Int |
| changeQuality | User changed quality | String |
| changeCaptions | User changed captions | Int |
| orientationChange | Orientation changed | PlayerOrientation |
| volumechange | User changed volume | Int |
| loaded | Video is loaded | Bool |
| next | Next video is loaded | Bool |
| share | User clicked share button | Bool |
| buffering | Video is buffering | Bool |
| buffered | Video buffered | Bool |
| nextVideoClicked | User clicked next video | Bool |
| previousVideoClicked | User clicked previous video | Bool |
Ad States
| PlayerState | Description | Value Return Type |
|---|---|---|
| adState | Current state of Ad | IMAAdEvent |
| adLoaded | Ad content loaded | Bool |
| adStarted | Ad content started | Bool |
| adComplete | Ad content Completed | Bool |
| adClicked | Ad content link clicked | Bool |
| adSkipped | Ad content skip clicked | Bool |
| adAllAdsCompleted | All Ad content completed | Bool |
| adFirstQuartile | First Quartile of Ad content watched | Bool |
| adMidpoint | Mid point of Ad content watched | Bool |
| adThirdQuartile | Third point of Ad content watched | Bool |
Status
You can get various player status from the app by setting the getStatusBlock function.
vpplayer.getStatusBlock {
[weak self]
(status)
in switch status {
case .failed (let error) : print (error)
case .ready : print ("Ready to Play")
case .playing : print ("Playing")
case .pause : print ("Pause")
case .end : print ("End")
default : break
}
}
| Status | Description |
|---|---|
| failed | Player failed to play video |
| ready | Player ready to play video |
| playing | Player playing video |
| pause | Player paused video |
| end | Video in player ended |
Player Orientation
You can get player orientation from the app by setting the getOrientationChange function.
vpplayer.getOrientationChange {
(status)
in print (status)
// prints player orientation status
}
| Status | Description |
|---|---|
| landscapeLeft | Player orientation landscape left. |
| landscapeRight | Player orientation landscape right. |
| portrait | Player orientation portrait. |