-
Notifications
You must be signed in to change notification settings - Fork 36
Using the video features
Our video functionality within the AmityUIKit allows for richer, interactive experiences by enabling live streaming on your application.
More than ever, videos are increasingly dominating mobile screens. From fun short-form clips to promote new products to live-streamed talk shows to educate your customers, videos have the potential to transform the way customers experience your brand.
The UIKit now supports live stream posts so you can create and watch live streams.
To enable live stream functionalities easily, we’ve provided AmityUIKitLiveStream, which is built on top of AmityUIKit and AmitySDK. The plugin provides:
-
LiveStreamBroadcastViewController
to create and broadcast live stream posts -
LiveStreamPlayerViewController
to watch live streams
The live stream plugin can be installed via Swift Package Manager with these steps:
- In Xcode, select File > Swift Packages > Add Package Dependency.
- Specify the Repository: https://github.com/AmityCo/Amity-Social-Cloud-UIKit-LiveStream-iOS-SwiftPM.
- Select Up to Next Major, then click Next.
- Select
AmityUIKitLiveStream
, then click Finish.
After successfully installing the plugin, you must override the live stream behaviors with these steps:
- Create
AmityEventHandler
subclass, and override live stream functions.
import UIKit
import AmityUIKit
import AmitySDK
import AmityUIKitLiveStream
class CustomEventHandler: AmityEventHandler {
override func createLiveStreamPost(
from source: AmityViewController,
targetId: String?,
targetType: AmityPostTargetType,
destinationToUnwindBackAfterFinish: UIViewController
) {
let broadcastVC =
LiveStreamBroadcastViewController(client: AmityUIKitManager.client, targetId: targetId, targetType: targetType)
broadcastVC.destinationToUnwindBackAfterFinish = destinationToUnwindBackAfterFinish
broadcastVC.modalPresentationStyle = .fullScreen
source.present(broadcastVC, animated: true, completion: nil)
}
override func openLiveStreamPlayer(from source: AmityViewController, postId: String, streamId: String) {
let playerVC = LiveStreamPlayerViewController(streamIdToWatch: streamId)
source.present(playerVC, animated: true, completion: nil)
}
}
- Set the custom event handler for
AmityUIKit
.
AmityUIKitManager.set(eventHandler: CustomEventHandler())
LiveStreamBroadcastViewController
requires these permissions:
- Camera Permission - to broadcast live stream video
- Microphone Permission - to broadcast live stream audio
After LiveStreamBroadcastViewController
is presented, it will prompt to ask permission automatically if needed. You must include these permission keys in your app’s Info.plist file:
- NSCameraUsageDescription
- NSMicrophoneUsageDescription