Completing a Live Contribution

After a Live Contribution is created, it can be modified to provide additional information. Then, once you're done recording, you need to finish the Live Contribution.

Update request

Because it may be hard to know beforehand what you are about to record, you may want to change the Live Contribution's information after it was created. This is a job for LiveContribution.UpdateRequest.

LiveContribution.UpdateRequest updateRequest = new LiveContribution.UpdateRequest(context, liveContribution, authenticatedClient)
    .setWhat("Actually, yet another cat video");

// Now execute the request in a background thread
RequestExecutor.executeBackground(updateRequest, new Request.ResponseListener<LiveContribution>()
{
    @Override
    public void onResponse(@NonNull LiveContribution contribution)
    {
        // The request succeeded. You may want to update the reference you kept of LiveContribution with this updated one.
        liveContribution = contribution;
    }
},
new Request.ErrorListener<LiveException>()
{
    @Override
    public void onError(@NonNull LiveException e)
    {
        // An error occurred
    }
});

On success, the request returns a new LiveContribution object with the updated information.

Finish request

When you create a Live Contribution, the Newzulu Live server will allocate resources to receive, record and forward the video stream from your application.

When you're done streaming, you need to execute a LiveContribution.FinishRequest in order to mark the Live Contribution as finished and enable its resources to be reallocated to another stream.

RequestExecutor.executeBackground(new LiveContribution.FinishRequest(liveContribution, authenticatedClient), new Request.ResponseListener<Void>()
{
    @Override
    public void onResponse(@NonNull Void aVoid)
    {
        // Contribution finished, good job !
    }
},
new Request.ErrorListener<LiveException>()
{
    @Override
    public void onError(@NonNull LiveException e)
    {
        // An error occurred.
    }
});

If you fail to execute that request, the server will automatically finish the Live Contribution after a pre-determined period of inactivity.