A Person
A Person

Reputation: 451

How can I change the stream my event uses via the YouTube live api?

So I have been looking for a way to get the 16 digit stream name from YouTube and i have finally found out how which is via this line of code ->

streamName = returnedStream.getCdn().getIngestionInfo().getStreamName();

stream name is just a String

If i try use .setStreamName();, it does not change the stream name. i tried giving the value of my previous stream I created but the same stays the same.

If i try use .setStreamName();, it does not change the stream name. i tried giving the value of my previous stream I created but the same stays the same. I tried doing this ->

returnedStream.getCdn().getIngestionInfo().setStreamName(title); 

but still does not work.

Upvotes: 0

Views: 615

Answers (1)

M. Prokhorov
M. Prokhorov

Reputation: 3993

Live broadcast is associated with a stream using a liveBroadcasts/bind method.

In terms of Java API it would look something like this:

YouTube yt = ...         // your reference to YouTube
String broadcastId = ... // your broadcast Id

String newStreamId = ... // identifier of stream you want to bind
String apiKEy = ...      // your API key

// you can define other response parts if you want more or don't want some of these
String responseParts = "id,status,contentDetails.boundStreamId";

yt.liveBroadcasts().bind(broadcastId, responseParts)
    .setApiKey(apiKey)
    .setStreamId(streamId)
    // other data you might want in request
    .execute()

API references:

Upvotes: 1

Related Questions