UizaSDK 8.5.0

UizaSDK 8.5.0

Maintained by Nam Kennic, deathemperor, Nam Nguyen.



 
Depends on:
Alamofire~> 4.9.1
SwiftyJSON>= 0
LFLiveKit_>= 0
NKModalViewManager>= 0
FrameLayoutKit>= 0
SDWebImage>= 0
Sentry>= 0
 

UizaSDK 8.5.0

  • By
  • Uiza

UizaSDK

Version License Platform Swift

(Kéo xuống phía dưới để đọc tiếng Việt)

UizaSDK is a framework to connect to Uiza system

Compatibility

UizaSDK requires Swift 4.0+ and iOS 8+

Installation

CocoaPods

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

pod 'UizaSDK'

Then run the following command:

$ pod install

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

[email protected]

License

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


UizaSDK

UizaSDK là bộ Framework hỗ trợ kết nối đến API của hệ thống Uiza

Tương Thích

UizaSDK yêu cầu Swift 4.0_ và iOS 8+

Cài Đặt

CocoaPods

Cài đặt thông qua CocoaPods

Thêm vào Podfile dòng sau:

pod 'UizaSDK'

Sau đó chạy lệnh này:

$ pod install

Cách Sử Dụng

Khởi tạo

Luôn khởi động framework này trước khi gọi bất cứ hàm API nào bằng cách gọi lệnh sau:

import UizaSDK

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

YOUR_APP_ID và YOUR_DOMAIN : lấy từ thông tin trong email đăng ký

TOKEN: được tạo từ trang https://docs.uiza.io/#get-api-key

API_VERSION: phiên bản API sử dụng, truyền vào .v3 hoặc .v4 (nếu không truyền, mặc định là .v3)

Gọi hàm API

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

Cách play video

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

Nếu gặp trường hợp video không play được do vấn đề App Transport Security (ATS), bạn phải thêm dòng sau vào file Info.plist để có thể play được video:

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

Cách phát livestream

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

Nhớ thêm mô tả yêu cầu chức năng truy cập camera và micro vào file Info.plist:

<key>NSCameraUsageDescription</key>
<string>App cần truy cập camera để phát livestream</string>
<key>NSMicrophoneUsageDescription</key>
<string>App cần truy cập micro để thu tiếng khi phát livestream</string>

Thay đổi giao diện

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

UizaPlayer có sẵn 7 giao diện sau:

UZTheme1

UZTheme2

UZTheme3

UZTheme4

UZTheme5

UZTheme6

UZTheme7

Tự tạo giao diện (CustomTheme)

Bạn có thể tự tạo giao diện riêng bằng cách tạo class kế thừa UZPlayerTheme Protocol theo mẫu code này: UZCustomTheme

Bạn cũng có thể thay đổi giao diện của màn hình kết thúc bằng cách tạo class kế thừa UZEndscreenView, sau đó đưa nó vào player.controlView.endscreenView

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

Tạo Player với Floating Mode

Bạn có thể tạo player với chức năng "kéo xuống góc màn hình" giống Facebook hoặc Youtube bằng cách tạo class kế thừa UZFloatingPlayerViewController, trong đó bạn có thể thêm các UI hiển thị chi tiết của video và đưa vào detailsContainerView

Sau đó present bằng lệnh sau:

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

Xem Ví dụ

Hỗ trợ Google ChromeCast

Nếu bạn sử dụng Xcode 10 và phát triển cho iOS 12 trở lên, cần phải bật "Access WiFi Information" thì chức năng tìm kiếm các thiết bị Cast mới có thể hoạt động

Xem chi tiết Tài liệu API

Hỗ Trợ

[email protected]