1 person found this helpful
There's no easy way to do this, but essentially what you want to do is 3 methods: play(), pause(), seek(0).
The exact pattern should be something like:
set the source
set autoPlay = false
// add listener for step1
step 1 (in mediaPlayerStateChangeHandler in the READY state):
videoPlayer.muted = true;
videoPlayer.view.visible = false;
// call play(), here, then wait to call pause() and seek(0) in the
// add listener for step 2
step 2 (in dimensionChangeHandler):
// the seek(0) is asynchronous so let's add an event listener to see when it's finsished:
// called play(), now call pause() and seek(0);
// add listener for step 3
step 3 (in seekEndHandler):
videoPlayer.muted = beforeLoadMuted;
videoPlayer.view.visible = true;
Hope that helps,
thanks for your reply ... that's more or less the way I've been trying to implement it.
are there any plans for a more straightforward implementation in the framework? I would guess that this is a very common feature
I don't work on the OSMF team, so I can't answer for them, but this approach to load up the first frame is not really recommended practice, so I wouldn't hold my breath waiting for them to implement this feature for you. That's because it downloads all this content automatically and makes tracking video views much harder.
A better approach to do this would be to load up a thumbnail or an Image at first. This will give the video its size and also display the frame you want before the user actually starts playing the video.