I’m building a repeater that houses a video player for an online course. I’ve set up the repeater so that the “Next Video” button only appears after the entire video has been played. This works great for the first video in the section, but when the user is advanced to the second video, the code recognizes that the previous video in the repeater had played and therefore displays the next button before the second video even starts.
My code is below:
$w.onReady(function () {
$w("#videoPlayer2").play();]
$w("#videoPlayer2").onEnded( (event) => {
$w("#button11").show();
$w("#image7").show();
})
});
How do I “reset” the video progress so the code only runs after each video ends?
https://www.wix.com/velo/reference/$w/videoplayer/seek
$w("#myVideoPlayer").seek(102)
2 .then( () => {
3 console.log("Done with seek, what to do now?");
4 } );
Thanks, I tried that but the issue still remains. When advanced to the second video the playhead still starts at zero, the problem is that since the first video in the repeater technically ended, the code runs but doesn’t restart once the repeater is advanced to the next item.
I suppose I could make each video a dynamic page but I wanted to see if there is an easy was to rest it so I don’t have to rebuild more pages
@juliatincombe
I can’t see any corresponding CODE, to tall you more about the behaviour of your coded elements.
EDIT: Ok, now i can see a CODE-snipet.
@russian-dima I just mean this section:
$w("#videoPlayer2").onEnded( (event) => {
$w("#button11").show();
has already run once and advancing to the next item in the repeater doesn’t prompt the code to run again.
@juliatincombe
What about…
$w.onReady(function () {
$w("#videoPlayer2").play();
$w("#videoPlayer2").onEnded((event) => {
$w("#videoPlayer2").stop()
$w("#button11").show();
$w("#image7").show();
})
});
But wait! You use it inside a repeater?
Then you might to code it this way…
$w.onReady(function () {
$w("#myRepeater").onItemReady(($item, itemData, index) => {
console.log(itemData)
$item("#videoPlayer2").play()
$item("#videoPlayer2").onEnded((event) => {
$item("#videoPlayer2").stop()
$w("#button11").show();
$w("#image7").show();
})
});
});
@russian-dima Unfortunately no luck with that either. Thank you for your help though! I think this may just be a limitation of using the different videos linked by a dataset within the same repeater. I may need to have each video be it’s own dynamic page to get it to work.