Anyone know if this can be done by inserting some HTML or Javascript into the YouTube embed code? I don't think a time-delayed redirect would be good, as it would redirect some viewers too early (for example those that get hung up with longer video buffering times, etc). Is there a simple way to detect when the video has finished playing, then redirect based on that? Thanks
Look at the API that youtube has available, I believe it is possible, but I havent gone in detail to check out here is some information: http://code.google.com/apis/youtube/articles/youtube_as3_chromeless.html#subscribing_to_events There is an event called YouTubeLoaderEvent.STATE_CHANGE so that should be able to pick up the end of the video.
One way I would do this by knowing when the video ends. Create a javascript function all the way at the bottom of the page before the ending body tag. When the page loads (body OnLoad function) run that function and have it wait for total seconds that video plays. How can you get the time it ends? See the RSS feed exposed by my youtube page (http://www.youtube.com/rajib2k5) http://www.youtube.com/api2_rest?method=youtube.videos.list_by_user&dev_id=Fwv7KWPaxvw&user=rajib2k5&page=1&per_page=10 There is a xml node namely length_second. That tells you how long that video runs for. Get that information via youtube api. You're all set after that. Let me know if this helps. Good luck!!!
Yea, that is a nice way, however if the person pause the video or if the internet is slow and it have to get the info the time will be off. So you will have times that it will stop before the video really done.
Those are good scenarios to test... The OnLoad function will trigger after everything is loaded. It'll be challenging to find out if the video connection is slow or not. I have not researched that aspect of the youtube api. My approach would work after everything is loaded. You're right that it does not account for video server connectivity issue. There are times YouTube is down for maintenance... What do you do then? My recommended approach is not the only way. I am looking forward to other solutions and what you ultimately decide. Depending on the end user or client you are serving, you have to make some assumption and/or trade off. Sorry I could not be of more help there. For your good question I added a plus to your reputation.
I am also interested in a solution, however I want to make a play list with links to different video providers, like youtube, googlevideo,dailymotion etc. I have now that I can play those on my website, however I would love to make it possible so that you can make a playlist with the music videos that are there. So that each visitor can make their own favorite top 10. So if someone has some good ideas how to go about it I also would love to hear about it.
hte only way to figure that out would be to reference the youtube api. if its not somewhere in there, you'd have to ask a developer on the youtube site.