YouTube Live Streaming API in swift

Viewed 2089

I'm so sorry for asking such a basic question.
I've been struggling for a few days.
Because Google api documents are really the worst.

Here's how I am now.

  1. With GoogleSignIn, OAuth is done. (It has information such as user ID, token, and API key...)

  2. Success fetch playlist


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. How to start Live Broadcast??
    I think it's a stupid question.
    But I'm really desperate.

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

According to this document, must specify a value for these properties.

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

And also required parameters is part.

"The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include.

The part properties that you can include in the parameter value are id, snippet, contentDetails, and status."

But what the hell is this? cotentDetails?? status?? snippet?? I couldn't find this information anywhere in the document. I don't know what to do. Please help me.

1 Answers

Based from this documentation:

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.

You need to provide a liveBroadcast resource in the request body. You may also check this link as an example.

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

Related