How To Use Live Stream SDK iOS Build App

davidrelo

DavidRelo

Posted on September 30, 2022

How To Use Live Stream SDK iOS Build App

More and more companies have launched their own iOS live stream SDK, which shows the rapid development trend of the live streaming market.

According to eMarketer forecasts, 2.72 billion people will watch videos on their mobile phones in 2023. That's up from 2.16 billion in 2019. This represents a compound annual growth rate (CAGR) of 6%—higher than the 4.5% CAGR for worldwide digital video viewers.

What features do you need for live streaming

With the continuous development of the live streaming industry, live streaming has been divided into several sub-industries.

such as game live streaming, education live streaming, live streaming with goods, and live streaming of entertainment.
Different live streaming industries require different functions.

Basic function:

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

Special function:

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

A complete live streaming application is a complex system. Most enterprises will use the live stream SDK for iOS to quickly build a live broadcast platform and occupy the live streaming market.

What support is provided by the live streaming SDK

The development of live streaming SDK is also developing in a simple and convenient direction, from providing the underlying audio and video transmission capability to a complete live streaming solution, to the current componentized solution.
It can not only meet the requirements of customers for rapid construction but also meet the various personalized needs of customers.

ZEGOCLOUD's latest ios live stream SDK - Live Streaming Kit. It is a componentized solution. The SDK encapsulates the live streaming function into an independent component and 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 demonstrate how to quickly build a live video streaming app.

Add ZegoUIKitPrebuiltLiveStreaming as dependencies

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

target 'ZegoCallDemo' do
  use_frameworks!

  # Pods for ZegoCallDemo
  pod 'ZegoUIKitPrebuiltLiveStreaming'

end
Enter fullscreen mode Exit fullscreen mode

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...
}
Enter fullscreen mode Exit fullscreen mode

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)
}

}
Enter fullscreen mode Exit fullscreen mode

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

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>
Enter fullscreen mode Exit fullscreen mode

video-sdk

Run the demo


Sign up with ZEGOCLOUD, and get 10,000 minutes free every month.

Did you know? 👏

Like and Follow is the biggest encouragement to me
Follow me to learn more technical knowledge
Thank you for reading :)

Learn more

This is one of the live technical articles. Welcome to other articles:

💖 💪 🙅 🚩
davidrelo
DavidRelo

Posted on September 30, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related