I want a video to play and then disappear after it finishes on my wix website and I have tried to use this code $w.onReady(function(){// Start the videoif($w("#videoPlayer1").isPlaying ){$w("#videoPlayer1").pause();}else{$w("#videoPlayer1").play();}setTimeout(()=>{$w("#videoPlayer1").hide();},10000);// 10000 is the time of your video in milliseconds});
and this code
$w.onReady(function () { $w('#videoPlayer1').onViewportEnter(()=>{ $w('#videoPlayer1').collapse() })
and it is still not working? please can someone help me ASAP I don't know what I am doing wrong
I have also tried this code as I didn't know if this is what you meant by changing the ID @Velo-Ninja
Hi, its playing but for some reason it is still not disappearing? Do you know why this could be? @Velo-Ninja
@Velo-Ninja Hi, sadly it's still saying this and not playing my video :( Any tips on how to fix this?
@Velo-Ninja Please read the above message
Hi, thank you for trying to help but when I do this it says that there is a type error? :( any idea as to why it is saying this?
I think there are a lot of possibilities of how to detect if a video is playing or not.
When using a VIDEO --> every VIDEO has a specific playtime.
Let us first take a quick look onto the Wix-VideoPlayer-API....
https://www.wix.com/velo/reference/$w/videoplayer
So which of the offered options you could use for your needs?
1) currentTime --> Could we maybe use this one? --> maybe!
2) duration --> Could we maybe use this one? --> maybe!
3) isPlaying --> Could we maybe use this one? --> maybe also possible!
But what about this one ???
onEnded( )
$w("#myVideoPlayer").onEnded((event) => { let targetId = event.target.id; // "myVideoPlayer" });
This should give you back as result the current ID of your VIDEO-ELEMENT, whose play-time has been ended (stopped)!