The live streaming market is booming
As an industry, live streaming is already worth billions of dollars and it’s only expected to grow.
According to various projections, including one by Grand View Research, the live streaming industry is expected to climb from $70
billion in 2021 to almost $224
billion in 2028. That’s a projected three-fold increase over seven years!
How to get involved in the live streaming market?
With the rapid development of the live streaming industry, many technology companies have been derived to serve the live streaming industry by providing mature technologies to help users quickly build their own live streaming apps.
Here I will introduce how to quickly build your own live streaming app by using ZEGOCLOUD's ZEGOLive SDK.
What features does ZEGOLive SDK provide?
The ZEGOLive SDK provides all features that required by a live streaming app, such as creating and join a live stream room, co-hosting, face beautification, audio effects, virtual gifting, sending bullet-screen messages, and more. And all these features can be tried out by simply experiencing and integrating ZEGOCLOUD's Demo App for Live Streaming.
The following table shows ZEGOLive SDK's features:
Feature | Description |
---|---|
Real-time audio and video | You can use to build smooth live streaming experiences with ultra-low latency. |
Room list | Room list shows the current ongoing live streaming. Users can enter the live room on the list to watch live streaming as wanted. |
Create a live room | You can create a live room and start your live stream after becoming the host of a room. |
Log in to a live room | Users need to log in to a live room first to play streams and join co-hosting. |
Request to co-host | Participants can request to take a co-host seat to be a co-host, and participants can speak and join the live streaming once the host accepts the request. |
Make co-hosts | The host can invite any participants in the room to co-host, and participants can decline or accept the invitation. |
Manage co-host seats | The host of a room can remove the co-hosts from the co-host seat, disable or enable the text chat for all participants, and more. 。 |
Real-time quality analysis |
|
Instant messaging | With the ZEGOCLOUD IM service, participants can send, receive real-time messages, get notified when new participants join the room or existing participants leave the room, and also can see the interactive notifications in the room. |
Audio effects | Support setting up the music accompaniments with genuine music, and provide rich audio effects, including reverb, voice changing, and more. |
Face beautify | Provide Face beautification feature to make you look more presentable: skin tone enhancement, skin smoothing, image sharping, cheek blusher, and more. |
How to use ZEGOLive SDK
step 1. Create a ZEGOCLOUD account
- Create an account in ZEGOCLOUD Official.
step 2. Create a new project
- Create a project in ZEGOCLOUD Admin Console.
step 3. Understand the process
The following diagram shows the basic process of creating a live room and a participant (user B) playing a stream published by the host (user A).
step 4. Integrate the ZEGOLive SDK
To integrate the SDK, do the following:
- Download the Sample codes, and copy the
ZEGOLive
folder to your project directory (create a new project if you don't have an existing project). -
Add the
Podfile
file to your project directory.
pod 'ZIM' pod 'ZegoExpressEngine'
-
Open Terminal, run the
install
command.
pod install
step 5. Add permissions
Permissions can be set as needed.
- Open Xcode, select the target object, and then click Info > Custom iOS Target Properties.
- Click the Add button (+) to add camera and microphone permissions.
Privacy-Camera Usage Description
Privacy-Microphone Usage Description
step 6. Initialize the ZEGOLive SDK
To initialize the ZEGOLive SDK, get the RoomManager
instance, pass the AppID of your project.
// Initialize the SDK. We recommend you call this method when the application starts.
// YOUR_APP_ID is the AppID you get from ZEGOCLOUD Admin Console.
RoomManager.shared.initWithAppID(appID: YOUR_APP_ID) { result in
// Callback for the result of init.
};
To receive callbacks, set the corresponding delegate
to self
, or call the addUserServiceDelegate
method to listen for and handle event callbacks as needed.
RoomManager.shared.roomService.delegate = self
RoomManager.shared.userService.addUserServiceDelegate(self)
RoomManager.shared.messageService.delegate = self
step 7. Log in
To access the ZEGOLive service, you must log in first.
- For business security, you will need to provide a token for the ZIM SDK to validate the login privilege. For details, see
Authentication
. - For debugging, you can refer to our Sample code to generate tokens on your app client.
let userInfo = UserInfo("YOUR_USER_ID", "YOUR_USER_NAME", .participant)
let token: String = "YOUR_TOKEN"
RoomManager.shared.userService.login(userInfo, token) { result in
// Callback for the login result.
}
step 8. Start the local video preview
Before creating a live room to start live streaming, you can call the playVideoStream
method to start the local video preview.
// The [userID] can be used to specify which user's view you want to view.
// To preview your own local video view, pass in your userID.
// streamView view is a view for the local video preview.
RoomManager.shared.deviceService.playVideoStream(userID, view: streamView)
step 9. Create/Join a live room
- You become a Host after creating a live room, and you can take a seat and start live streaming upon creating.
- You become a Participants after joining a live room, and you can watch the live streaming and be a
co-host
to interact.
- To prevent the participants from speaking directly without co-hosting, you will need to provide a Token for the RTC SDK to validate whether you have the privileges to create or join a room. For details, see
Use Tokens for authentication
. - This Token can be the same as the Token you provided for login.
To create a live room, call the createRoom
method.
RoomManager.shared.roomService.createRoom("YOUR_ROOM_ID", "YOUR_ROOM_NAME", token) { result in
// Callback for the result of create a live room.
}
After a live room is created, to start live streaming, the host will need to call the takeSeat
method to speak. And the SDK automatically publishes the streams when the host takes a seat successfully.
RoomManager.shared.userService.takeSeat { result in
// Callback for the result of take a seat.
}
To join a live room, call the joinRoom
method.
RoomManager.shared.roomService.joinRoom("YOUR_ROOM_ID", token) { result in
// Callback for the result of join a live room.
}
After joining a live room, for a participant to watch the live streaming, he will need to call the playVideoStream
method to play the host's published streams.
// The [userID] can be used to specify which user's view you want to view.
// You can get the userID of the host in room info.
// streamView is the view to be displayed.
RoomManager.shared.deviceService.playVideoStream(userID, view: streamView)
step 10. Send/Receive text messages
To send text messages in the room, call the sendTextMessage
method.
RoomManager.shared.messageService.sendTextMessage("MESSAGE_CONTENT") { result in
// The result of send messages.
}
To receive the text messages, listen for the callback receiveTextMessage
.
func receiveTextMessage(_ message: TextMessage) {
// Implement the handling logic when receiving the text messages.
}
step 11. Renew a Token
30 seconds before a Token expires, the SDK sends out a notification through the onRoomTokenWillExpire
callback.
Upon receiving this callback, you need to get a new Token from your app server first, and then pass the new token to the renewToken
method.
func onRoomTokenWillExpire(_ remainTimeInSecond: Int32, roomID: String?) {
let token: String = xxxxx ///new token
RoomManager.shared.roomService.renewToken(token, roomID: roomID)
}
step 12. Leave a live room
Before the host leaves the live room, he will need to call the leaveSeat
to leave the seat first. And the SDK automatically stops publishing streams when the host leaves the seat successfully.
RoomManager.shared.userService.leaveSeat { Result in
// Callback for the result of leave a seat.
}
To leave the live room, call the leaveRoom
method. And the SDK stops all the stream publishing and playing operations simultaneously.
RoomManager.shared.roomService.leaveRoom { Result in
// Callback for the result of leave a live room.
}
step 13. Log out
To finish the ZEGOLive service, call the logout
method.
RoomManager.shared.userService.logout()
If you want to learn more about live broadcast-related technologies.
You can follow me or send me email
Email:zegoclouddev@gmail.com
Top comments (0)