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 billion in 2021 to almost billion in 2028. That’s a projected three-fold increase over seven years! $70 $224 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: 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 , and copy the folder to your project directory (create a new project if you don't have an existing project). Sample codes ZEGOLive Add the file to your project directory. Podfile pod 'ZIM' pod 'ZegoExpressEngine' Open Terminal, run the command. install 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 to add camera and microphone permissions. Add button (+) Privacy-Camera Usage Description Privacy-Microphone Usage Description step 6. Initialize the ZEGOLive SDK To initialize the ZEGOLive SDK, get the instance, pass the AppID of your project. RoomManager // 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 to , or call the method to listen for and handle event callbacks as needed. delegate self addUserServiceDelegate 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. <div class="mk-warning"> 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 to generate tokens on your app client. </div> Sample code 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 method to start the local video preview. playVideoStream // 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 after creating a live room, and you can take a seat and start live streaming upon creating. Host You become a after joining a live room, and you can watch the live streaming and be a to interact. Participants co-host <div class="mk-warning"> 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. </div> To create a live room, call the method. createRoom 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 method to speak. And the SDK automatically publishes the streams when the host takes a seat successfully. takeSeat RoomManager.shared.userService.takeSeat { result in // Callback for the result of take a seat. } To join a live room, call the method. joinRoom 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 method to play the host's published streams. playVideoStream // 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 method. sendTextMessage 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 callback. onRoomTokenWillExpire Upon receiving this callback, you need to get a new Token from your app server first, and then pass the new token to the method. renewToken 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 to leave the seat first. And the SDK automatically stops publishing streams when the host leaves the seat successfully. leaveSeat RoomManager.shared.userService.leaveSeat { Result in // Callback for the result of leave a seat. } To leave the live room, call the method. And the SDK stops all the stream publishing and playing operations simultaneously. leaveRoom 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 method. logout 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 Also published here.