# ByteArk Lighthouse
# Features
- Track video playback analytics with ByteArk Lighthouse (opens new window)
# Plugin requirements
- iOS 14 or higher
- Xcode
- Swift 5.5
- ByteArkPlayerSDK version >= 0.2.1
# Plugin installation
# CocoaPods (Recommended)
gem install cocoapods
1
- Add the ByteArk Player SDK iOS CocoaPods repo:
pod repo add byteark-player-sdk-ios-specs https://github.com/byteark/byteark-player-sdk-ios-specs.git
1
- Modify your
Podfile:
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/byteark/byteark-player-sdk-ios-specs.git'
1
2
2
- Add the plugin:
pod 'ByteArkPlayerSDKLighthousePlugin', '~> BYTEARK_PLAYER_SDK_LIGHTHOUSE_PLUGIN_VERSION'
1
- Run
pod install.
# Swift Package Manager
- In Xcode, go to File > Add Packages.
- Enter
https://github.com/byteark/byteark-player-sdk-ios-lighthouse-plugin. - Select the version.
# Usage
# Basic usage
import UIKit
import ByteArkPlayerSDK
import ByteArkPlayerSDKLighthousePlugin
class PlayerViewController: ByteArkPlayerViewController {
override func viewDidLoad() {
super.viewDidLoad()
do {
// Create the Lighthouse config with your projectId
let lighthouseConfig = try ByteArkPlayerLighthouseConfigBuilder(projectId: "YOUR_PROJECT_ID")
.build()
// Create the Lighthouse plugin
let lighthousePlugin = ByteArkPlayerLighthousePlugin(with: lighthouseConfig)
// Build a player item
let item = try ByteArkPlayerItemBuilder()
.media(URL(string: "<MEDIA_URL>")!)
.title("Big Buck Bunny")
.build()
// Configure the player with the Lighthouse plugin
let config = try ByteArkPlayerConfigBuilder()
.item(item)
.autoplay(true)
.addPlugin(plugin: lighthousePlugin, name: ByteArkPlayerLighthousePlugin.PluginName)
.build()
player.configure(with: config)
} catch {
print(error.localizedDescription)
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Sending playback metadata
// Build playback metadata
let playbackMetadataBuilder = PlaybackMetadataBuilder()
// Set user metadata
playbackMetadataBuilder.userId(value: "user123")
playbackMetadataBuilder.city(value: "bangkok")
// Set the metadata on the plugin
lighthousePlugin.setPlaybackMetadata(playbackMetadataBuilder.build())
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Note
The title of ByteArkPlayerItem is required when using Lighthouse for tracking.
For more information about ByteArk Lighthouse, see the Lighthouse documentation (opens new window).