Skip to main content

MaestroKit: Admin Video Publisher Documentation

AdminVideoPublisher is a full screen view that displays an admin's camera feed and gives them the ability to publish it live

Usage

import MaestroKit
import SwiftUI

struct ContentView: View {
@EnvironmentObject var maestroSDK: Maestro
let channelId: String
let siteId: String
let userJwt: String
let profileView: AnyView?

var body: some View {
maestroSDK.adminVideoPublisher(
channelId: channelId,
siteId: siteId,
userJwt: userJwt,
profileView: profileView
)
}
}

struct AdminProfileView: View {
var body: some View {
HStack {
Text("Custom Profile View for AdminVideoPublisher")
}
}
}
let adminProfile = AnyView(AdminProfileView())

struct ContentView_Previews: PreviewProvider {
@EnvironmentObject static var maestroSDK: Maestro
static var previews: some View {
ContentView(
channelId: "YOUR_CHANNEL_ID",
siteId: "YOUR_SITE_ID",
userJwt: "YOUR_USER_JWT",
profileView: adminProfile
)
.environmentObject(maestroSDK)
}
}

Parameters

The Admin Video Publisher view accepts the following parameters:

channelId (required)
The unique ID of the Maestro channel for which you want to display the live stream.
siteId (required)
The unique ID of Maestro's site.
userJwt (required)
User Token
profileView (optional)
Built a custom profile view, wrap the view with AnyView(), and pass it as an argument
  • If profileView does not receive an argument, the Admin Icon is hidden within the navigation bar
  • If using UIKit, highly recommend building the custom profile view using SwiftUI, and then passing that view when invoking this method in the UIKit view

Behavior

As the Admin Video Publisher view gets rendered, it will immediately attempt to access the user's camera, so a permission prompt will be presented, which requires NSCameraUsageDescription, NSMicrophoneUsageDescription, and NSPhotoLibraryUsageDescription to be set in Info.plist. This component also allows for changing between front-facing and rear-facing cameras, as well as changing the focus point by tapping on the desired region on the camera view (on supported devices). Upon initialization, this view also activates the current AVAudioSession and updates its category to .playAndRecord, mode: .voiceChat, and options: [.defaultToSpeaker, .allowBluetooth]. When tapping the Go Live button, it will establish an RTMP connection and publish the stream to viewers. Assuming photo library permission was given, it will also start recording the video locally.

Errors

If errors occur in the go live process, message dialogs will be shown according to the following map:

"Looks like you are already live in some other device."
Our backend sees that some other device is currently publishing to that channel, so it cannot go live.
"No connection could be established. Are you connected to the internet?"
The RTMP connection could not be made. This most likely relates to internet connection or ISP/VPN-related peculiarities like disallowing RTMP itself or underlying protocols.
"Live functionality is currently unavailable. Please try again later."
Some other unknown issue.