Create 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.

LiveContribution.CreateRequest request = new LiveContribution.CreateRequest(context, authenticatedClient)
    .setTitle("You won't guess what this developer is about to do")
    .setWhat("Live test session, take #42")
    .setWhere("Lyon, France")
    .setLatitude(45.7656250)
    .setLongitude(4.8359375);

// Now execute the request in a background thread
RequestExecutor.executeBackground(request, new Request.ResponseListener<LiveContribution>()
    {
        @Override
        public void onResponse(@NonNull LiveContribution contribution)
        {
           // The request succeeded. You want to keep a reference to that contribution to use it later for update or finish.
           liveContribution = contribution;
        }
    },
    new Request.ErrorListener<LiveException>()
    {
        @Override
        public void onError(@NonNull LiveException e)
        {
            // An error occurred.
        }
    });

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 LiveException is passed to the ErrorListener, which contains information about what went wrong. The error has a Type property that can be one of the following cases:

  • NETWORK: A network error occurred and the SDK was unable to reach the remote server.
  • SERVICE_ERROR: The remote server encountered an error, you should try again later.
  • UNKNOWN: An unknown internal error occurred.