Displays the current YouTube live video from a specified channel.
|Author:||Andrew Minion (profile at wordpress.org)|
|WordPress version required:||3.6|
|WordPress version tested:||4.8.1|
|Added to WordPress repository:||15-11-2016|
|Total downloads:||1 612|
Click to start download
- Upload this folder to the
/wp-content/plugins/directory or install from the Plugins menu in WordPress
- Activate the plugin through the Plugins menu in WordPress
- Add your Google API key and YouTube Channel ID in the settings page (Settings > YouTube Live)
- Add the shortcode
[youtube_live]into any post/page to show the live player
How does this work?
This plugin uses Google’s YouTube Data API to search for in-progress live videos and if one is found, embeds it in the page.
API stands for “Application Programming Interface,” which basically means computer code that is able to talk to other computer systems and get or send information. Most API providers require an API key of some sort (similar to a username and password) to ensure that only authorized people are able to use their services.
What info is sent or received?
When the shortcode is used in a page, your web server makes a request to YouTube’s servers asking for information about the videos in your channel, using your channel ID and API key to authenticate. If you don’t have an API key set up or it’s not authorized for the YouTube Data API, the request will be denied.
For more information on setting up an API key, see the YouTube Data API reference; for purposes of this plugin, you’ll need a “browser key.”
Why doesn’t my live stream show up immediately?
Generally, it can take up to a minute or two for the streaming page with the shortcode to recognize that you have a live stream, for several reasons:
- YouTube’s API caches information about your videos for a short time (I couldn’t find any documentation on how long exactly, but seems to be around 30 seconds)
- To help you from exceeding the free API quota, this plugin caches YouTube’s API response for 30 seconds (configurable using the
wp_youtube_live_transient_timeoutfilter) instead of checking the API every time an update is requested
- If you are using a caching plugin (WP Super Cache, W3 Total Cache, etc.), the page content is cached. However, this plugin provides a workaround by sending an Ajax request from the user’s browser when the page is loaded, and then every 30 seconds thereafter until a live video is available (also configurable using the
In short, there’s a tradeoff between showing the live video immediately and minimizing API quota and server resource usage, and I’ve tried to strike a reasonable balance, while allowing you the ability to tweak the cache timeouts yourself to fit your needs.
- Fix error handling
- Add error handling for API key issues
- Fix some miscellaneous PHP issues
- Add a JS event for custom uses
- Add settings for default width and height
- Add setting for auto-refresh feature
- Add support for a fallback video if no live stream is available
- Add support for a channel player if no live stream is available
- Automatically recheck every 30 seconds to see if a live stream is available
- Minor fix for
no_stream_messageattribute handling for real this time
- Minor fix for
- Minor fix for
- Minor fix for an upgrade issue if the subdomain was not set after an upgrade
- Add support for pre-shortcode “no stream available” message
- Add support for gaming.youtube.com subdomain
- Fix minor readme formatting issues
- Fix minor issues
- Use curl instead of file_get_contents as it didn’t work reliably on some hosting environments.
- Add a visual spinner when checking via Ajax
- Cache results to reduce API calls (defaults to 30-second expiration)
- Add Ajax button to check from client-side for live video
- Add debugging information for logged-in users
- Use PHP class instead of unreliable client-side JS to search for live videos
- Initial release