Forum Moderators: not2easy

Message Too Old, No Replies

Video player that starts automatically when scrolling down

autoplay

         

ldor

11:05 am on Jun 2, 2020 (gmt 0)

5+ Year Member



Hi

In some sites, including Facebook, if there is a frame with a video player, when scrolling down the page the player starts playing automatically when it approaches the center of the screen. When scrolling further, it stops playing even before it disappears from the screen.

Does anybody know how to make such a player?

In the examples I saw there is also a Play/Pause button, so that the visitor can stop the player without scrolling it further. And in some sites there is also a switch to disable autoplay. That also would be very helpful.

not2easy

12:03 pm on Jun 2, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



A lot depends on the site's platform/environment and the formats of your videos. There are plugins and scripts or basic html5 elements. The simplest method to show videos in HTML is to use the <video> element.

We don't do tutorials here, but there are free tutorials to build your own html5 video player with options for control at https://www.w3schools.com/html/html5_video.asp for example.

ldor

1:20 pm on Jun 2, 2020 (gmt 0)

5+ Year Member



Thank you. Somehow I didn't think that html5 has an autoplay attribute. I will try it. Not sure though if it works the way I described (autoplay starts only when the player window is scrolled close to the center of the screen).

As for the format of the video, that is not a problem, it can be converted to any format

ldor

1:38 pm on Jun 2, 2020 (gmt 0)

5+ Year Member



I have checked html5, unfortunately the autoplay does not work that way. I mean, it works regardless of the player position on the screen, not only when the player is close to the center of the screen.

not2easy

3:09 pm on Jun 2, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



You do realize that most people do not appreciate Auto-Play? It can cause them to close the browser or hit the back button if they are not expecting it.

NickMNS

3:17 pm on Jun 2, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



@Idor I assume you need to use JS, add a scroll event that when triggered starts the video, and another that stops it.

That said and to not2easy's point people really hate autoplay, and I believe (I'm not sure) that some browser's disable it by default.

lucy24

4:12 pm on Jun 2, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



:: insert boilerplate about why the ### would you want to create something that will cause at least half of all users to close the tab instantly ::

ldor

4:17 pm on Jun 2, 2020 (gmt 0)

5+ Year Member



I guess, if the player is muted nobody is going to hate it, especially if it occupies a relatively small part of the screen. It will look just like an image but an animated one.

And yes, probably the best solution is to use Javascript. Thank you

NickMNS

6:07 pm on Jun 2, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I guess, if the player is muted nobody is going to hate it,

True, if by nobody, you meant all those people who don't care about websites voraciously eating up all their bandwidth for no reason.

tangor

9:47 pm on Jun 2, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Autoplay is kiss of death ... has been since the beginning.

One reason why script blockers and ad blockers exist. One reason why modern browsers defeat autoplay. One reason why once stung the visitor will never return.