How To Use

UizaSDK

Version License Platform Swift

UizaSDK is a framework to connect to Uiza system

Compatibility

UizaSDK requires Swift 4.2 and iOS 8+, TVOS 10+

Installation

CocoaPods (Recommended)

To integrate UizaSDK into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'UizaSDK' // for iOS 10+
pod 'UizaSDK8' // for iOS 8,9
pod 'UizaSDK' , '~> 7.0.6-swift3' // for Swift 3.x

Then run the following command:

$ pod install

Manual Installation

Download UizaSDK.framework and drag it into your project, add it to Embbeded Binaries section

Usage

Framework Init

Always initialize the framework by the following line before calling any API functions:

import UizaSDK

UizaSDK.initWith(appId: YOUR_APP_ID, token: TOKEN, api: YOUR_DOMAIN, version: API_VERSION)

YOUR_APP_ID and YOUR_DOMAIN : get from registration email

TOKEN: generate from https://docs.uiza.io/#get-api-key

API_VERSION: version of target API, set .v3 or .v4 (default is .v3)

Call API

UZContentServices().loadDetail(entityId: ENTITY_ID, completionBlock: { (videoItem, error) in
  if error != nil {
    print("Error: \(error)")
  }
  else {
    print("Video: \(videoItem)")
  }
})

How to play video

let playerViewController = UZPlayerViewController()
playerViewController.player.loadVideo(entityId: ENTITY_ID)
present(playerViewController, animated: true, completion: nil)

You might have to add these lines to Info.plist to disable App Transport Security (ATS) to be able to play video:

<key>NSAppTransportSecurity</key>  
<dict>  
  <key>NSAllowsArbitraryLoads</key><true/>  
</dict>

How to broadcast livestream

let viewController = UZLiveStreamViewController()
viewController.liveEventId = ENTITY_ID
self.present(viewController, animated: true, completion: nil)

Remember to add these usage description keys into Info.plist file:

<key>NSCameraUsageDescription</key>
<string>App needs access to camera for livestream</string>
<key>NSMicrophoneUsageDescription</key>
<string>App needs access to microphone for livestream</string>

Change Player Themes

let playerViewController = UZPlayerViewController()
playerViewController.player.theme = UZTheme1()

UizaPlayer currently has 7 built-in themes:

UZTheme1

UZTheme2

UZTheme3

UZTheme4

UZTheme5

UZTheme6

UZTheme7

Create CustomTheme

You can create your own custom theme by creating a class inheriting from UZPlayerTheme Protocol following this template: UZCustomTheme

You can also create your custom end screen by subclassing UZEndscreenView, then set an instance to player.controlView.endscreenView

self.playerViewController.player.controlView.endscreenView = MyCustomEndScreen()

Create Player with Floating Mode

You can create player with "drag down to floating mode" like Facebook or Youtube, by subclassing UZFloatingPlayerViewController, then you can add more UI for displaying video details and add them to detailsContainerView

Then present using this code:

UZFloatingPlayerViewController().present(with: videoItem, playlist: playlist)

See Example

For API details, check API Document

Google ChromeCast supports

If developing using Xcode 10 and targeting iOS devices running iOS 12 or higher, the "Access WiFi Information" capability is required in order to discover and connect to Cast devices

Support

namnh@uiza.io

License

UizaSDK is released under the BSD license. See LICENSE for details.