Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed new Youtube's live video permanent URL?

I stream live on youtube a lot and since yesterday I experience a weird thing:

I embedded the livestream URL in my site. it was youtube.com/embed/ABCDE (normal embed link). That link used to show the current livestream and not a specific video. for example:

I'm streaming and you can watch it on youtube.com/embed/ABCDE. When i'm finished, the video gets its own url, something like youtube.com/watch?v=FGHIJ. In the next time I will stream, users can watch the stream on youtube.com/embed/ABCDE (that was a permanent url that didn't change).

Now, every time I stream, the livestream get its own link at first place, which means I have to update my embed code manually every time I stream.

I researched a bit around Google, SO and YouTube and I found out that a livestream's permanent url is youtube.com/channel/CHANNEL_ID/live. It's awesome and all, but I can't find a way to embed it.

(I use wordpress and I didn't find any plugin to do it automatically for me).

TL:DR; how to embed the livestream in the page youtube.com/channel/CHANNEL_ID/live?

like image 979
Itay Ganor Avatar asked Sep 01 '16 15:09

Itay Ganor


People also ask

Can you reuse YouTube livestream link?

Reuse stream settingsYou can easily create a new stream using the same settings as a previous stream. The new stream will copy all of the previous stream's metadata, settings, and the stream key. You'll have a chance to change the stream after it's created. To get started, select your stream and click Reuse settings.

Can I create a YouTube live link in advance?

Scheduling your live stream to your YouTube channel in advance allows you to inform your viewers ahead of time that you will be going live. When you schedule a stream to YouTube, it creates a video on your channel under the “Upcoming Live Streams” area with the date and time of your scheduled stream.


2 Answers

The embed URL for a channel's live stream is:

https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID 

You can find your CHANNEL_ID at https://www.youtube.com/account_advanced

like image 52
audiomason Avatar answered Oct 27 '22 18:10

audiomason


The issue is two-fold:

  1. WordPress reformats the YouTube link
  2. You need a custom embed link to support a live stream embed

As a prerequisite (as of August, 2016), you need to link an AdSense account and then turn on monetization in your YouTube channel. It's a painful change that broke a lot of live streams.

You will need to use the following URL format for the embed:

<iframe width="560" height="315" src="https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID&autoplay=1" frameborder="0" allowfullscreen></iframe> 

The &autoplay=1 is not necessary, but I like to include it. Change CHANNEL to your channel's ID. One thing to note is that WordPress may reformat the URL once you commit your change. Therefore, you'll need a plugin that allows you to use raw code and not have it override. Using a custom PHP code plugin can help and you would just echo the code like so:

<?php echo '<iframe width="560" height="315" src="https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID&autoplay=1" frameborder="0" allowfullscreen></iframe>'; ?> 

Let me know if that worked for you!

like image 30
Ahmed Sagarwala Avatar answered Oct 27 '22 16:10

Ahmed Sagarwala