I want to make video posts redirect to the next video post in it’s category after it’s over. I use both youtube videos and directly uploaded videos both of which I already know how to pull the duration in seconds. How can I use them to accomplish my goal?
Leave a Reply
You must be logged in to post a comment.
Notes before
What you’re asking for is a highly complex thing:
The problem is not the redirect 1), but more how you want to know how & when to load the next post.
1) Which in fact(/imho) should be an ajax load & replace of the current post.
YouTube API
You can check if the video is finished with a simply javascript listener
Available Return values:
Link to Google-YouTubeAPI function here
As an easy start: You need to a) have a listener that catches the player state when it changes and b) fires of the ajax call.
The ajax call would be a simple wordpress default call to reload the content of (for example) the parent div of the player. Just search through the ajax archives here on the page if you don’t know how WP handles ajax requests.
Internal (your personally hosted) videos
Here’s the real problem. You need a player that offers the same as the YouTube player: A possibility to retrieve a status change when the video playback was finished. This highly depends on the player and I’ve no recommendation at this point.
Your chance!
There’s the »JavaScript API for a chromeless player«. A quote from the YouTube API:
A last note from YouTube.