Persistent video stream with PHP / JS - javascript

I'm looking for a way to create a movie stream that works much like a TV channel. Basically the movies play constantly, whether people are viewing the page or not. Users might come to the page and the current movie is halfway through. Once one movie is done, the next one plays, and so on.
I can't figure out how to make this work, though. Right now I have the player working where every time the page is loaded a random video is chosen and played, but this isn't what I want. Does anyone have any ideas on how I might get this to work?

You need to keep a schedule of your video stream in a storage. This way you know which video is going to be played or be playing at any given time.
Now I know this is not the exact way a streaming service would work but it will get the job done for you. When a user loads a page your system computes which video should be playing at that time. Once the video is chosen, your system should compute the difference in the current time and the time when the video was supposed to start. Then you adjust the seek in your player i.e. you provide the start time of the video to the player as the time difference between the current time and the time when the video was supposed to start. This makes the video play from a position which is not necessarily its start.
Hope this helps.

Related

Specifying download timestamp limit of html5 audio element

I am making an app for a book, and part of it involves audio. The book is broken up into chapters and each chapter has about 10 sections. The sound engineer who made the audiobook broke the files up into chapters, but the book itself is broken up into readable sections. Therefore I need to way to play only a specific part of the chapter.
I know you can use URLs to specify timestamps using ...mp3#t=00:03:26. But I'm not exactly sure of the behaviour the download will play after.
The starting of the file works fine, but I'm worried about what happens when it gets to the end of a section. I suppose I could put an event listener on the audio element to check to see if the time has reached the next section's timestamp. The issue I'm facing is that involves trying to conserve bandwidth because that's our main cost.
If the browser decides to download the rest of the audio file, then let's say you're at section 3 and your browser downloads section 4,5, and 6. Then when you go to section 4 it re-downloads a part of what it already downloaded.
There are a number of 'other' solutions but what I mainly want to is understand how the browser determines the timestamp at which it 'stops' downloading. I assume that when it is playing live, it only downloads x amount of seconds in advance. If this is a low number, it's not a big deal. But if the browser skips ahead it could incur a lot of costs, in which case I would need to 'cap' it somehow.
The audio engineer doesn't want to break the files up into sections because then there are quality losses for re-compression.

Expo-AV play audios after another

I'm using Expo-AV and I'm trying to find a simple way to play 3 audio files after another.
I can't find anything online, does anyone have experience with Expo-AV?
Much appreciated.
The docs for expo-av show an example that plays from a playlist of media. It's a bit of a wordy example since it covers a lot of cases, but it does what you want it to do.
This line shows how they initialize Audio.Sound.createAsync - the third argument is a callback that runs when the playback state changes. In that callback, you can check if the audio has finished playing, and play the next sound if so. The example does this here.

Solution to accuratly determine or set frame rate and callback on new rendered frames locally

I was curious if anyone knew of a solution for loading and playing a video, and determining the frame rate, or being able to set this frame rate and will accurately tell you when a new frame is rendered. From what I have found the only way to get the current location of the html 5 video player is the current time attribute. This, however only updates around 4-5 times a second for me. I need to update the page every frame. Does anyone know any solutions to this? I was thinking maybe I can locally stream FFMPEG to my electron window however this seems overly complicated. I have seen some of the costly libraries but I have not seen an up-to-date opensource solution to this. Any Ideas?

Intervals and server load

Okay, me and a couple of friends had the idea to make a website where you can earn some credits and later on wager these credits, all fun and stuff. Everything works but now we are stuck on a gamemode we thought of.
(BustABit Solo) How the gamemode works is a player chooses a wager amount, then starts the game. When the player has clicked start on the backend there will be a 'crash number' generated on which the game will end. Then on the browser a counter will count up from 1.00x to infinite. Let's say the server decided to crash the game on 2.00x. If a player clicked the cashout button on let's say 1.50x, then he'll get 1.50x (150%) his wager.
Now where the problem lays, the server needs to keep track on what number the player cashs' out, therefor we need some sort of interval (or do we?) to keep track on what number the crash is when the player clicks the cashout button. But there could be over two hundred people at the same time playing which all would need their own interval (?), wouldn't it be a giant load on the server? How do we go about this correctly?

How to make a message pop up(hover) when the player hits a time instant?

I want to do the same for a video player, I suspect it is no different because we are talking about the time instants irrespective of the player.
Like in this link.
So, what kind of coding goes into this?
What kind of player would you be using? You see, in the example you posted a link to, you can rewind the player, and the timeline will reset to the current playback time, and so will the messages (comments) popping up. If your player does not support rewinding (time-jump). You could set the timeout when the user clicks play, and then show the popups respectively.
If however your player supports the feature of moving the playhead, first we (at least I do) need to know what kind of player you'd be using. If it is a Audio API based player, I can help you.
Hope this clarifies things for you.

Categories

Resources