How to create a live video stream from YouTube?

I program a stream of youtube videos that should play according to a set schedule, like a TV. If you enter the website, the video stream must be taken on any video in the schedule. Therefore, and not a playlist set to order a video, this is a video schedule.

I started to encode it as a list of youtube ID codes, video length and video playback time. In fact, the program checks the current time, and then finds the video closer to that time. Then he will find the difference between the current time (in real time) and the time at which the video should be played, and thus speed up the rewinding of this time difference in the video.

Is this a dumb way to do this? I am writing in PHP. I feel that there is a better way to do this than to manually enter all the information into the list. And also, is there any other way to say playing this NOW and no matter who opens it, this is the current video that needs to be played. A cron task that updates every x minutes, checks the current video and saves it, and then plays that video?

Hope you guys could help me with this logic.

Thanks!

+7
source share
2 answers

Here is my suggestion:

1) Have a database with a video link and the scheduled time to start the video.
2) On your page, if the user visits the page, check the time and compare it with the youtube runtime in the database.
3) If it is greater than or equal to the database time, play the video.
4) You can add ajax and check the time in real time and go to the next video if the time is equal to the next video.

+1
source

Create an array of links: it’s better if they are stored in a database with a scheduled time

Replace the source code of the html element after the time has been deleted.

for this you need an asynchronous type of object.

-one
source

All Articles