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

ぃ、小莉子 提交于 2020-01-25 08:53:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!