如何通过YouTube实时API更改活动使用的视频流? [英] How can I change the stream my event uses via the YouTube live api?
问题描述
因此,我一直在寻找一种从YouTube获取16位数字流名称的方法,最后我通过这行代码找到了它的状态->
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();
流名称只是一个字符串
如果我尝试使用.setStreamName();
,它不会更改流名称.我尝试给出我创建的上一个流的值,但保持不变.
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.
如果我尝试使用.setStreamName();
,它不会更改流名称.我尝试给出我创建的上一个流的值,但保持不变.我尝试这样做->
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);
但仍然无法正常工作.
推荐答案
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参考:
- YouTube
- LiveBroadcasts.bind method
- LiveBroadcasts.Bind request
- Available response fields
这篇关于如何通过YouTube实时API更改活动使用的视频流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!