Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a live stream of youtube videos?

I'm programming a stream of youtube videos that should play on a set schedule, similar to television. If you enter the website the video stream should pick up at whatever video is up in the schedule. So rather than a playlist set by an order of videos, it's a schedule of videos.

I started coding it as a list of youtube ID codes, the length of the video, and the time the video should play. Essentially the program will check the current time, and then find the video closest to that time. Then, it will find the difference between the current time (real-world time) and the time that video should play, and thus fast forward that video 'time difference' seconds.

Is this a silly way to do it? I am writing in PHP. I feel like there's a better way to do it than to manually enter all of the info into the list. And also, is there another way to say, play this NOW and no matter who opens it, this is the current video that should be play. A cron job that updates every x minutes, checks the current video and stores it, and then plays that video?

I hope you guys could help me with this logic.

Thanks!

like image 322
Daniel Fein Avatar asked Jan 15 '13 01:01

Daniel Fein


1 Answers

Here is my suggestion:

1) Have a Database with the video link and the scheduled time for the video to run.
2) In your page, if an user is visiting the page, check the time and compare it with your youtube run time in the database.
3) If its greater or equal to the database time, play the video.
4) You can add some ajax and check the time in realtime and move to the next video if the time is equal to the next video.

like image 90
Purus Avatar answered Sep 19 '22 14:09

Purus