问题
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.
回答1:
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:
- YouTube
- LiveBroadcasts.bind method
- LiveBroadcasts.Bind request
- Available response fields
来源:https://stackoverflow.com/questions/57785543/how-can-i-change-the-stream-my-event-uses-via-the-youtube-live-api