ios - 快速的 YouTube 直播 API

标签 ios swift youtube youtube-api youtube-data-api

很抱歉问了这么简单的问题。
我已经苦苦挣扎了几天。
因为谷歌的api文档真的是最烂的。

这就是我现在的样子。

  1. 有了 GoogleSignIn,OAuth 就完成了。 (它有用户 ID、 token 和 API key 等信息……)

  2. 成功获取播放列表


func fetchPlaylist(id: String) {
    let url = self.baseURL + "/playlists"
    let params = ["part": "snippet", "id": id, "key": self.apiKey]

    Alamofire.request(url, method: .get, parameters: params, encoding: URLEncoding.default, headers: nil).responseJSON { (response) in
        if let response = response.result.value {
            print(response)
        } else {
            print("error")
        }
    }
}
//////////// 👇result👇
{
    etag = "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/ewwRz0VbTYpp2EGbOkvZ5M_1mbo\"";
    items =     (
    );
    kind = "youtube#playlistListResponse";
    pageInfo =     {
        resultsPerPage = 5;
        totalResults = 0;
    };
}
  1. 如何开始直播??
    我认为这是一个愚蠢的问题。
    但我真的很绝望。

https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/insert

根据此文档,必须为这些属性指定一个值。

  • snippet.title
  • snippet.scheduledStartTime
  • status.privacyStatus

还有一部分是必需的参数。

“part 参数在此操作中有两个用途。它标识写入操作将设置的属性以及 API 响应将包含的属性。

您可以在参数值中包含的部分属性有 id、snippet、contentDetails 和 status。”

但这到底是什么?详细信息??状态??片段?? 我在文档的任何地方都找不到此信息。 我不知道该怎么办。 请帮助我。

最佳答案

基于此文档:

contentDetails

  • The contentDetails object contains information about the video content, including the length of the video and an indication of whether captions are available for the video.

status

  • The status object contains information about the video's uploading, processing, and privacy statuses.

snippet

  • The snippet object contains basic details about the video, such as its title, description, and category.

您需要提供一个 liveBroadcast resource在请求正文中。您也可以查看此 link举个例子。

YTLiveStreaming

YTLiveStreaming is a framework for creating live broadcasts and video streams on YouTube using the YouTube Live Streaming API (YouTube Data API v3) in Swift 4

关于ios - 快速的 YouTube 直播 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53809966/

相关文章:

youtube - 是否可以允许许多用户使用YouTube API和一个帐户进行直播?

ios - 使用 TrueTime 获取设备独立时间的可靠性如何?

ios - 为什么我的代码不起作用? - setObject ForKey : key cannot be nil

ios - 如何在快速嵌入导航堆栈的 View Controller 中隐藏选项卡栏?

ios - 使用解析和 url 填充 UItableview

Javascript 生成的 ul 在 Internet Explorer 中看起来不同

javascript - 如何编写将显示 youtube iframe 的自定义按钮,寻求开始视频然后播放

ios - XLForm 如何添加两个 BooleanCheck 导入互斥关系

ios - 在 setAttributedTitle 之后无法更改 UIButton 标题

ios - 添加 UICollectionView 后 iOS 9 中的自定义键盘崩溃