/** * @param string $title * @return \Google_Service_YouTube_LiveStream */ protected function createStream($title) { $streamSnippet = new \Google_Service_YouTube_LiveStreamSnippet(); $streamSnippet->setTitle($title); $cdn = new \Google_Service_YouTube_CdnSettings(); $cdn->setFormat('720p'); $cdn->setIngestionType('rtmp'); $streamInsert = new \Google_Service_YouTube_LiveStream(); $streamInsert->setSnippet($streamSnippet); $streamInsert->setCdn($cdn); $streamInsert->setKind('youtube#liveStream'); return $this->youTubeApiClient->liveStreams->insert('snippet,cdn', $streamInsert); }
$broadcastInsert->setStatus($status); $broadcastInsert->setKind('youtube#liveBroadcast'); // Execute the request and return an object that contains information // about the new broadcast. $broadcastsResponse = $youtube->liveBroadcasts->insert('snippet,status', $broadcastInsert, array()); // Create an object for the liveStream resource's snippet. Specify a value // for the snippet's title. $streamSnippet = new Google_Service_YouTube_LiveStreamSnippet(); $streamSnippet->setTitle('New Stream'); // Create an object for content distribution network details for the live // stream and specify the stream's format and ingestion type. $cdn = new Google_Service_YouTube_CdnSettings(); $cdn->setFormat("1080p"); $cdn->setIngestionType('rtmp'); // Create the API request that inserts the liveStream resource. $streamInsert = new Google_Service_YouTube_LiveStream(); $streamInsert->setSnippet($streamSnippet); $streamInsert->setCdn($cdn); $streamInsert->setKind('youtube#liveStream'); // Execute the request and return an object that contains information // about the new stream. $streamsResponse = $youtube->liveStreams->insert('snippet,cdn', $streamInsert, array()); // Bind the broadcast to the live stream. $bindBroadcastResponse = $youtube->liveBroadcasts->bind($broadcastsResponse['id'], 'id,contentDetails', array('streamId' => $streamsResponse['id'])); $htmlBody .= "<h3>Added Broadcast</h3><ul>"; $htmlBody .= sprintf('<li>%s published at %s (%s)</li>', $broadcastsResponse['snippet']['title'], $broadcastsResponse['snippet']['publishedAt'], $broadcastsResponse['id']); $htmlBody .= '</ul>'; $htmlBody .= "<h3>Added Stream</h3><ul>"; $htmlBody .= sprintf('<li>%s (%s)</li>', $streamsResponse['snippet']['title'], $streamsResponse['id']); $htmlBody .= '</ul>'; $htmlBody .= "<h3>Bound Broadcast</h3><ul>";