Reputation: 11
Total newbie here. I'm making a choose-your-own-adventure which relies on a video being played based on one of two choices you are given (think Bandersnatch, basically).
Using a single video player introduces a short pause when videos are switched, which I do not want. My aim is to have two video players prepare the next two videos in advance so that one can be played instantly if the corresponding choice is selected.
I have all the information for each branch (the video to play, the two videos for the next choices, button text etc) stored in scriptable objects so I can access this easily. Also, I have a variable for activePlayer, which is given the current video to play, as well as choice1Player and choice2Player, which are given the next potential videos to prepare.
I am struggling with the logic of how to switch the activePlayer to one of the other two players when a choice is selected, and then to change the current activePlayer into the new choice1 or choice2 player based on what needs to be prepared. My head says this is quite a simple task, but logic is failing me utterly. Any pointers would be greatly appreciated!
Upvotes: 1
Views: 48
Reputation: 25491
A common approach, and possibly the simplest, sometimes used for switching between a main video and ad's, is to simply hide and pause/stop one player while unhiding and playing the other.
So you effectively always have two active players, but you simply hide one at any given time - i.e. you are not switching the active player, both are always active and you are just controlling what the user can actually see.
On a webpage, you could use CSS to hide and unhide the videos while on a mobile you might make a particular layer or view visible.
Upvotes: 0