Video Vs VideoPlayer

Hi guys,
I’m wondering if there’s any benefit in using video instead of videoPlayer.
On one hand, the API for a video player is much richer and includes more functions,
But on the other hand… what? Is the performance of video better? (Why should we use video?)

Thanks

Don’t forget that video is for Vimeo and Youtube, whilst videoPlayer is for both of them and Dailymotion, Facebook. Twitch, along with other videos uploaded to your site.

I would personally always go for videoPlayer on preference so that I could have more control over everything as well as the additional features too, however it will all depend on what yourself or your client wants or needs etc.

Plus, I am sure that somebody will say that they will prefer to use video instead.

Another thing, when I use $videoPlayer.play(), it doesn’t start plaing. Maybe, you’ll be able to help me with that.

$w("#videoPlayer1").src = videoLink;//some Youtube link passed from the page to the video lightbox
  $w("#videoPlayer1").show()//The player gets shown, the src is correct
  .then(() => {$w("#videoPlayer1").play()})//it doesn't start playing!!!
  .then(() => {console.log("playing")})//it logs "playing"
  .catch((err) => console.log(err));

Thanks

Well, it’s a mystery. It must be something with the timing, because if I put the .play() inside a setTimeout of 1s it works fine.
Can anyone enlighten me?

I can’t see any reason why it doesn’t or shouldn’t if you have the element on screen for the user to click the play button so that.

Plus, you are setting the video through the src so Wix knows where to get the video to play from.
$w(‘#videoPlayer1’).src = ‘wix:video://v1/11062b_735a34726eb64df29a56b30b60fe2db8/_#posterUri=11062b_735a34726eb64df29a56b30b60fe2db8f000.jpg&posterWidth=1920&posterHeight=1080’;

Or when you have it with an event handler like onClick
export function playButton_onclick(event) {
$w(“#myVideoPlayer”).play();

or

$w(“#playButton”).onClick( (event) => {
$w(“#myVideoPlayer”).play();

Or you wrap it all up in the page onReady function for example

$w.onReady(function () {
$w(“#myVideoPlayer”).play();

or

$w.onReady( () => {
$w(“#myVideoPlayer”).play();

Or you use the isPlaying function to check if the video is playing and if not set to play.

if( $w(“#myElement”).isPlaying ) {
$w(“#myElement”).pause();
}
else {
$w(“#myElement”).play();
}

However, you would probably want to use Pause.

if( $w(“#myElement”).isPlaying ) {
$w(“#myElement”).play();
}
else {
$w(“#myElement”).pause();
}

Like here if you want to hide the videoplayer if there is no video file to play.

Plus check to see if you have used togglePlay to as that could cause it to be paused when you want it to be playing instead.

Also, if you are using an videoplayer element, then check to see what your autoplay settings are on too, as if it is disabled then the user will need to click play to get it going.

Otherwise, it could be that autoplay is paused unless sound is muted.
https://support.wix.com/en/article/adding-a-videobox

Finally, note that some browsers have changed things so videos don’t autostart etc.

Although, doing a little digging through old posts, there was a reply by Yisrael about this and this is what he says…

You will need to use the Video component for Youtube videos as they are handled differently by the Youtube system.

So, apparently videoplayer can’t use Youtube videos even though it says it can.

Hmm, so it must have a slight pause at the start then before it starts playing, if setTimeout works then use it, you could even put one at the end to hide it too or use the onEnded function to fire an event handler to hide it instead
https://www.wix.com/corvid/reference/$w.VideoPlayer.html#onEnded .

$w.onReady(function () {
setTimeout(() => { $w(“#videoPlayer1”).hide(); }, 5000);

@givemeawhisky yes. apparently this timeout helps on desktop, but for mobile it somehow stops playing immediately. Unexpected behavior.
The problem with using Video instead of videoPlayer, is that Video doesn’t have the .play() function at all.
Thank you for the answers, Whisky. :slight_smile:

@jonatandor35

Have you got it as a separate element or is it in something like a video lightbox?

If in lightbox, then the slight time issue shouldn’t be a problem.

I know video backgrounds have a slight pause before playing, so maybe that time delay is common throughout all elements concerning videos.

@givemeawhisky I put a videoPlayer in a lightbox.
Now I also tried to trigger .play() in an onClick() handler (just to test if it works at all) and it did work on desktop and failed on iPhone.

@jonatandor35 Remember that some browsers now don’t allow autoplay if sound is not muted.

Maybe that’s it (although I’ve tested it with several browsers).
The .play() was able to resume playing (on mobile), but not to start playing. So It’s probably the browser restrictions.

Plus I’ve only got access to Android phones, so I can’t test myself on Apple device.

@jonatandor35 Yes, just rechecking Wix pages again.
https://support.wix.com/en/article/autoplay-on-desktops-and-laptops

It should work okay on Ipad as that is treated as landscape the same as desktop, however it is just on iphone etc then.

Assuming video backgrounds work fine if you set them up to run on mobile in the mobile settings?

Don’t forget, if it is browser restrictions then it should be Wix Support for help before they send you straight back here!

Plus, don’t ask Yisrael, he is currently still knee deep in clearing up all those upturned desks in the office, well that is all apart from his which never got messed up and is still in pristine condition with everything as it is :stuck_out_tongue_winking_eye:

@givemeawhisky so it goes like that:

  1. Desktop - needs timeout.
  2. Android - can be triggered on button click, but not on time out.
  3. iPone (Safari & Chrome) - doesn’t work at all.

As for Wix support, a few days ago, I contacted them regarding a critical bug that happens if you open the site from a link in Gmail app (on iPhone only). The support person told me not to use Gmail app. So I don’t think I’ll contact them ever again.

@jonatandor35
Okay so at least you can set it up to suit desktop and mobile versions now though.

However, Wix Support reply about using Gmail, or rather not using Gmail, that sort of smacks in the face and gives a can’t be bothered to answer or find out a reason why reply.

Can understand if they told you to go through Google as you are using Gmail or to go through Apple for Iphone etc, however to simply tell you just to stop using it is pretty bad, especially when you mention about a critical bug as that isn’t going to be solved simply by yourself not using it.

Absolutely stupid. :scream:

@givemeawhisky yes. I asked him if it was a known bug and he didn’t know, so he tried to transfer the call to someone who was supposed to know, but after waiting a while on the line, listening to some boring music, I hang up.
That was disappointing phone cal indeed.

@jonatandor35 Sorry to hear that, so far I’ve not had any issues with Wix Support, please not let it start now.

Maybe try them again one day as it might have just been a bad day for one of the advisors, like they had lost their script or I might be thinking of other call centres here!