Ok, So I found the event listener code:
However I’m not sure where to use this. In the functions.php file?
window.addEventListener(‘wpYouTubeLiveStarted’, function() {
/* your code here */
console.log(‘stream started’);
/* your code here */
});
Thanks!
No, you’d put this in a javascript file and then include that using your functions.php file.
So you’d create a video-ticker.js file in your theme folder containing something like this:
(function($){
$('document').ready(function() {
window.addEventListener('wpYouTubeLiveStarted', function() {
// swap out the content of .ticker-box
$('.ticker-box').html('Breaking LIVE now! <a id="expand-video">Open Video viewer</a>');
});
$('#expand-video').on('click', function() {
// do stuff here to make video visible
});
});
Then in functions.php, add this to load it on the frontend:
function my_video_ticker_js() {
wp_enqueue_script( 'my-video-ticker', get_stylesheet_directory_uri() . '/video-ticker.js', array( 'jquery' ), NULL, true );
}
add_action( 'wp_enqueue_scripts', 'my_video_ticker_js' );
Greetings Andrew,
Thanks for the programming advice and speedy turnaround time on my last support request.
I have now been doing rather extensive testing with the plugin with excellent results. However, I’ve run into another issue regarding the fallback_behavior once the video stream ends in that the iFrame window stays open on the page. I expected (incorrectly?) that the browser would recheck for the stream, and finding none, the iFrame would clear. That does not happen.
In checking wp-youtube-live.js, I see that there is no code to change the state of the now dead stream back to the original pre live stream state.
Here’s my page and code:
Live Stream page
[youtube_live auto_refresh=”true” autoplay=”true” js_only=
“true” fallback_behavior=”no_message”]
This works excellently (other than a large time lag anywhere from 90 to 300 seconds.)
Once the live video finishes. The iFrame stays on the page and does not refresh/revert to the original state.
Can you suggest code to make the iFrame close and return to the original page as seen at the above link?
Thank you!