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

前端 未结 3 1948
死守一世寂寞
死守一世寂寞 2020-12-07 13:05

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

相关标签:
3条回答
  • 2020-12-07 13:17

    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

    0 讨论(0)
  • 2020-12-07 13:28

    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!

    0 讨论(0)
  • 2020-12-07 13:28

    Have you tried plugin called " Youtube Live Stream Auto Embed"

    Its seems to be working. Check it once.

    0 讨论(0)
提交回复
热议问题