Creating a Live Contribution
Once the AuthenticatedClient
is created, you are almost ready to stream. But first you need to create a Live Contribution.
A LiveContribution
object contains the information associated with your stream. Creating a Live Contribution on the Newzulu Live server allows you to describe the subject and location of your stream and also request the server to allocate the resources required to to receive, record and forward the video stream from your application.
Create request
To create a new Live Contribution, you use a LiveContribution.CreateRequest
.
var request = LiveContribution.CreateRequest()
request.fields.title = "You won't guess what this developer is about to do"
request.fields.what = "Live test session, take #42"
request.fields.where = "Lyon, France"
request.fields.latitude = 45.7656250
request.fields.longitude = 4.8359375
let operation =
request.operation(with: authenticatedClient, queue: .main, onSuccess: { liveContribution in
// The request succeeded. You want to keep a reference to that contribution to use it later for update or finish.
contribution = liveContribution
}, onError: { error in
// An error occurred.
})
operation.start()
On success, the request returns a LiveContribution
object. You can now pass this object to a LiveRecorder
.
Next step: start recording
Handling errors
If the request fails, a NewzuluError
is passed to the onError
block, which contains information about what went wrong. The error has a reason
property that can be one of the following cases:
.networkFailure
: A network error occurred and the SDK was unable to reach the remote server..wrongCredentials
: The client used its credentials to authenticate prior to fetching the media but they're are not valid..serverFailure
: The remote server encountered an error, you should try again later..invalidRepresentation
: The response from the remote server cannot be understood..unknown
: An unknown internal error occurred.
As
NewzuluError
is declared in the Newzulu Core framework, you need toimport NewzuluCore
in your source file when dealing with errors.