# Getting Started
ATTENTION
The Unified Plugin currently only supports CDN Balancer product
Codavel Unified Plugin can be integrated with an iOS app that relies on the following video players:
- AVPlayer
# How to Install
The installation of the Unified Plugin can be performed via Swift Package Manager or via Cocoapods.
# Swift Package Manager
Open your Xcode project, then go to File > Add Packages
Enter the repository URL:
https://repo.plugin.npaw.com/release/plugin-ios.git
On the Dependency Rules, select Exact Version, and type
7.1.2
Choose the target/project in which you want to add the package, then click Add Package
You should now see the UnifiedPluginPkg (and also GCDWebServers) added as a dependency in the Swift Package Manager section of your project.
ATTENTION
If the project does not build, go to the project name in the Project Navigator on the left side, click on your current target under "Targets" and make sure UnifiedPlugin is shown under "Frameworks, Libraries, and Embedded Content" section. If not, click "+" button and choose "UnifiedPlugin", then click "Add".
# Cocoapods
- If you don't have Cocoapods installed, install it first by running the following command in your terminal:
gem install cocoapods
- Navigate to your project's root directory in the terminal and run:
pod init
This will create a Podfile in your project directory.
- Open the Podfile with a text editor and add the private repository source and the UnifiedPlugin dependency:
source 'https://cdn.cocoapods.org'
source 'https://repo.plugin.npaw.com/release/plugin-ios-cocoapods.git'
target 'YourAppTargetName' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for YourAppTargetName
pod 'UnifiedPluginPkg', '7.1.2'
end
2
3
4
5
6
7
8
9
10
Save and close the
Podfile
.Run the following command in the terminal to install UnifiedPlugin:
pod install
This will create an .xcworkspace
file. Make sure to open your project using this .xcworkspace
file from now on.
- Now the UnifiedPlugin should be integrated into your iOS project using Cocoapods.
# Unified Plugin Lifecycle
To initialise the Unified Plugin, first, it needs to be imported on every class it will be used:
import UnifiedPlugin
Then, it can be created with the account code provided on the Codavel Panel:
var unifiedPluginInstance = UnifiedPluginInstance.Builder(accountCode: "yourAccountCode")
.build()
2
WARNING
It is important to maintain only one instance of the Unified Plugin throughout the app.
Finally, modify the content-url
to play by calling the unifiedPluginInstance.getResource
, and pass it to the AVPlayer instance.
// fetch the new URL from Codavel Unified Plugin
guard let url = URL(string: unifiedPluginInstance.getResource(url: "<content-url>")) else { return }
// initialize the player with the new URL
let player = AVPlayer(url: url)
// start the player
let controller = AVPlayerViewController()
controller.player = player
present(controller, animated: true) {
player.play()
}
2
3
4
5
6
7
8
9
10
11
12
13
NOTICE
The CDN Balancer module only supports content with the following extensions:
- mp4
- m4s
- ts
- cmf
- m3u8
- mpd
# Next Steps
At this point, your integration of the Codavel Unified Plugin is concluded.
After running your application, you should see your metrics appearing in your Codavel Panel dashboards.
# Further Customizations
The plugin allow you to configure different parameters in your integration, such as the metadata of the video playing. Detailed explanations of these options are available here.