Wir verwenden die YouTube Live Streaming-API in Verbindung mit der Google API PHP Client und ich kann nicht herausfinden, wie Sie eine grundlegende (voreingestellte) Aufnahme anstelle von a Gewohnheit eins.Verwenden der einfachen Aufnahme bei Verwendung der YouTube Live Streaming-API oder Vermeiden doppelter benutzerdefinierter
Benutzerdefinierte sind OK, aber aus irgendeinem Grund, auch wenn Sie sie den gleichen Namen nennen, erstellt es kontinuierlich Duplikate für jeden von Ihnen erstellten Stream.
Also meine Frage ist, wie bekommen wir es zu grundlegenden Einnahme oder in der Lage, eine benutzerdefinierte zu wählen, ohne jedes Mal ein neues zu erstellen?
Zum Beispiel hier ist die grundlegende Einnahme Sie, wenn Sie Setup einen Stream manuell in Ihrem YouTube-Konto auswählen:
Die entsprechende PHP Code:
// Create an object for the liveBroadcast resource's snippet. Specify values
// for the snippet's title, scheduled start time, and scheduled end time.
$broadcastSnippet = new Google_Service_YouTube_LiveBroadcastSnippet();
$broadcastSnippet->setTitle($this->title);
$broadcastSnippet->setDescription($this->desc);
$broadcastSnippet->setScheduledStartTime($this->start_time);
// Create an object for the liveBroadcast resource's status, and set the
// broadcast's status.
$status = new Google_Service_YouTube_LiveBroadcastStatus();
$status->setPrivacyStatus($this->privacy_status);
// Create the API request that inserts the liveBroadcast resource.
$broadcastInsert = new Google_Service_YouTube_LiveBroadcast();
$broadcastInsert->setSnippet($broadcastSnippet);
$broadcastInsert->setStatus($status);
$broadcastInsert->setKind('youtube#liveBroadcast');
// Execute the request and return an object that contains information
// about the new broadcast.
$broadcastsResponse = $this->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($this->stream_title);
// 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();
# TODO: Update the below `Format` method to use the new 'resolution' and 'frameRate' methods
$cdn->setFormat($this->format);
$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 = $this->youtube->liveStreams->insert('snippet,cdn', $streamInsert, array());
// Bind the broadcast to the live stream.
$bindBroadcastResponse = $this->youtube->liveBroadcasts->bind(
$broadcastsResponse['id'], 'id,contentDetails',
array(
'streamId' => $streamsResponse['id'],
));
Aktualisierte Frage, um ein Beispiel für * basic ingestion * zu zeigen. – Brett
@Brett hat meine Antwort aktualisiert. – JAL
Ja, ich kenne das veraltete 'cdn.format', aber unglücklicherweise hat der' Google API PHP Client' keine Unterstützung für die neue Art, dies zu tun, noch AFAIK; zumindest im Zweig V1. – Brett