VMSPlayerController. iOS
Uses pusher-websocket-swift of 10.0.1 version with some fixes for VMSMobileSDK purposes.
https://github.com/pusher/pusher-websocket-swift/tree/master
Initialization
static func initialization(viewModel: VMSPlayerViewModel, delegate: VMSPlayerDelegate?) -> VMSPlayerController
VMSPlayerViewModel
init(
camera: VMSCamera,
groupCameras: [VMSCamera]?,
user: VMSUser,
translations: VMSPlayerTranslations,
playerApi: VMSPlayerApi,
options: VMSPlayerOptions
)
camera
- camera you want to open player for
groupCameras
- if you set this parameter you can swipe inside player to change camera playing in player
user
- current user
translations
- dictionary of translations needed inside player. You can make it based on the on you receive from server. See StaticsApi
for details
playerApi
- basically VMSMobileSDK
object. Or custom object that implements CameraApi
, PlayerApi
and CameraEventsApi
options
- custom options you can set for player
VMSPlayerOptions
init(
language: VMSLanguage?,
allowVibration: Bool?,
allowSoundOnStart: Bool?l,
markTypes: [VMSEventType],
videoRates: [VMSVideoRates]?
)
language
- default is english
allowVibration
- set to no
if you don't want device to vibrant when clicking on some options. Default is yes
allowSoundOnStart
- indicates if allow player to start audio if camera has sound right after player loaded. Default is true
markTypes
- array of available mark types. See StaticsApi
for more information
videoRates
- array of available player video rates. See StaticsApi
for more information
VMSOpenPlayerOptions
Additionally you can set open options if you need to open player in specific conditions.
init(
event: VMSEvent?,
archiveDate: Date?,
showEventEdit: Bool,
popNavigationAfterEventEdit: Bool,
pushEventsListAfterEventEdit: Bool,
openArchive: Bool
)
event
- event you want to show / edit in player. Parameter isEventArchive
will be set to true
automatically
archiveDate
- set date if you need to open archive at specific date
showEventEdit
- set this parameter to true
if you want to open event editing screen. event
should be set as well
popNavigationAfterEventEdit
- set this parameter to true
if you want player controller to be popped after saving or canceling event editing
pushEventsListAfterEventEdit
- set this parameter to true
if you want to show events list screen after saving or canceling event editing
openArchive
- set this parameter to true
if you want to open archive in player controller
VMSPlayerDelegate
VMSPlayerController uses VMSPlayerDelegate
playerDidAppear()
- get called when player loaded and appeared on screen
gotoEventsList(camera: VMSCamera)
- get called when button «Events list» pressed
soundChanged(isOn: Bool)
- get called when button «mute/unmute» pressed
screenshotCreated(image: UIImage, cameraName: String, date: Date)
- get called when screenshot captured fom current frame
logPlayerEvent(event: String)
- if you want to log user activity, this method provides the action's names to transfer to your app
playerDidReceiveError(message: String)
- show player error
playerDidReceiveInfo(message: String)
- show player info
dismissPlayerErrors()
- if you show views for error that have lifetime, dismiss them
Update player
Player respond to these notification names in order to handle them ad be updated accordingly
extension Notification.Name {
static let noConnectionError
static let updateUserPermissions
static let updateUserCameras
static let updateMarks
static let updateMark
}
noConnectionError
- post this notification in case there is no connection. Player will stop playing
updateUserPermissions
- in case user's permissions were changed player needs to be updated
updateUserCameras
- in case you received camerasUpdate
socket and current camera was removed from user's account player will be closed properly. It's a preferable way of closing player
updateMarks
- in case you received socket push markCreated
or markDeleted
use this notification to update player
updateMark
- in case you received socket push markUpdated
use this notification to update player