Talk to us
Talk to us
menu

Blog Post

start building
Company

How To Use Live Stream SDK iOS Build App

How To Use Live Stream SDK iOS Build App

Given the rapid growth of the live streaming market, many companies have launched their own iOS live stream SDK.

According to eMarketer forecasts, 2.72 billion people will watch videos on their mobile phones in 2023. In 2019 the number was 2.16 billion, increasing with a compound annual growth rate (CAGR) of 6%.

What features do you need for live streaming

With the continuous expansion of the live streaming industry, this industry specializes in several sub-industries: game live streaming, education live streaming, sales live streaming, and entertainment live streaming.

Different live streaming industries require specific functions.

The essential functions are:

  • Room management
  • Audio and video push-pull stream management
  • Device management
  • Member management
  • Barrage

Among advanced functions, there are:

  • Screen sharing
  • shopping cart
  • Gift effects
  • Host PK
  • Make co-hosts

A comprehensive live streaming application is a complex system. Most enterprises opt for a live stream SDK for iOS to quickly build a live broadcast platform and access the live streaming market.

What support is provided by the live streaming SDK

The development of live streaming SDK is also evolving in a simple and convenient direction, from providing the underlying audio and video transmission capability for a complete live streaming solution to the current compact solution. Besides meeting customers’ requirements for rapid construction, it satisfies various personalized needs.

ZEGOCLOUD’s latest iOS Live Streaming SDK Kit constitutes a compact, independent component solution that provides rich UI custom interfaces. Users select components according to their own needs and customize the UI.

How to build an app with live streaming SDK

Next, I will use the live video streaming iOS SDK to quickly demonstrate how to build a live video streaming app.

1) Add ZegoUIKitPrebuiltLiveStreaming as dependencies

Integrate ZegoUIKitPrebuiltLiveStreaming SDK through the pod as follows, add pod ZegoUIKitPrebuiltLiveStreaming in Podfile file. Then execute the command pod install it in Terminal. For detailed operation, please refer to Quick Access Documentation.

target 'ZegoCallDemo' do
  use_frameworks!
 
  # Pods for ZegoCallDemo
  pod 'ZegoUIKitPrebuiltLiveStreaming'
 
end

2) Import ZegoUIKitSDK & ZegoUIKitPrebuiltCall to your project

In the file that needs to be called the SDK interface, import the SDK through import.

import ZegoUIKitSDK
import ZegoUIKitPrebuiltLiveStreaming
// YourViewController.swift
class MainViewController: UIViewController {
    //Other code...
}

3) Using the ZegoUIKitPrebuiltLiveStreamingVC in your project

  • Go to ZEGOCLOUD Admin Console, get the appID and appSign of your project.
  • Specify the userID and userName for connecting the Live Streaming Kit service.
  • liveID represents the live streaming you want to start or watch (only supports single-host live streaming for now).
// YourViewController.swift
class MainViewController: UIViewController {
    // Other code...
    var userID: String = <#UserID#>
    var userName: String = <#UserName#>
    var liveID: String = <#liveID#>
 
func startLive() {
        let config: ZegoUIKitPrebuiltLiveStreamingConfig = ZegoUIKitPrebuiltLiveStreamingConfig(kPresetRoleHost)
        let liveVC: ZegoUIKitPrebuiltLiveStreamingVC = ZegoUIKitPrebuiltLiveStreamingVC(yourAppID, appSign: yourAppSign, userID: self.userID, userName: self.userName, liveID: self.liveID, config: config)
        liveVC.modalPresentationStyle = .fullScreen
        self.present(liveVC, animated: true, completion: nil)
}
 
func watchLive() {
      let config: ZegoUIKitPrebuiltLiveStreamingConfig = ZegoUIKitPrebuiltLiveStreamingConfig(kPresetRoleAudience)
      let liveVC: ZegoUIKitPrebuiltLiveStreamingVC = ZegoUIKitPrebuiltLiveStreamingVC(yourAppID, appSign: yourAppSign, userID: self.userID, userName: self.userName, liveID: self.liveID, config: config)
      liveVC.modalPresentationStyle = .fullScreen
      self.present(liveVC, animated: true, completion: nil)
}
 
}

Then, you can start live streaming by presenting the liveVC.

4) Configure your project

Open the Info.plist, add the following code inside the dict part:

<key>NSCameraUsageDescription</key>
<string>We require camera access to connect to a call</string>
<key>NSMicrophoneUsageDescription</key>
<string>We require microphone access to connect to a call</string>

Run the demo

ZEGOCLOUD
ZEGOCLOUD With our fully customizable and easy-to-integrate Live SDK, you can quickly build reliable, scalable, and interactive live streaming into your mobile, web, and desktop apps.

Related posts

Contact us