Figuring out how to do things in Brightcove is crazy hard. There is a ton of information on the old version of the api, but the latest/greatest is strangely hard.
I'm trying to set up a reset for the video. When the video ends, I want to basically reset the player to it's initial state.
The best I've been able to come up with is to detect "ended" event and tell it to play, and then to pause it some time afterward.
This seems very ghetto and I have to think there's a better way. I'd like to re-show the Poster, for example, and the BigPlayButton, etc.
I see a reset method but I don't see that it's doing anything.
This is my current implementation:
var heroVideo;
videojs("heroPlayerID").ready(function () {
heroVideo = this;
}).on('ended', function(){
heroVideo.play();
setTimeout(function(){
log('paused');
heroVideo.pause();
}, 1500);
});
Update
After reading this about using CSS to show/hide elements, I added the following css to my stylesheet:
.vjs-has-started.vjs-ended .vjs-poster,
.vjs-has-started.vjs-ended .vjs-big-play-button{
display: inline-block !important;
}
I also added this to my javascript event handler:
.on('ended', function(){
heroVideo.controls(true); // the controls never appear again if you don't do this
});
Now, everything works just like I want to.