Auto pause video player on scroll out of view down the web page (like facebook) ?

  • you could use the event onviewchange and then a spheretoscreen check on the hotspots coordinates. If spheretoscreen doesnt return good values its not on the screen. You can then use delayedcall so that your code only runs every half second or so, to lighten the cpu if it seems heavy as onviewchange can sometimes be a bit heavy.

  • Thanks, I'll give that a try. But wondering if the extra onviewchange CPU demand may defeat my purpose of stopping the video when not in view to free up the CPU!

    I'm wanting to run the Player at the top of the web page, but have it stop pause or unload on scroll out of view to free up resources for additional media further down the page. (Perhaps setting the code to run every few seconds would still accomplish this?) I just need the top player to stop before the second player is started. It likely takes a few seconds for a visitor to meander down the page and click on second player. I just need the code to run often enough to beat the visitors mouse click event.

    Edited 2 times, last by SpinStudios (March 16, 2015 at 8:41 PM).

  • Code
    <events name="TestPlayerinView" keep="true" onviewchanged="hotspots_visiblity();"/>
    <action name="hotspots_visibility">
       spheretoscreen(hotspot[spot].ath, hotspot[spot].atv, layer[spot].x, layer[spot].y, atv, hotspotcenterx, hotspotcentery);
    trace(hotspotx); 
    trace(hotspoty); 
    if(x != 0, ifnot(x, set(is_visible,false); ));
    if(is_visible,false, plugin[videoPlayer].stop();
    if(is_visible,false, plugin[videoplayer].play();
       	delayedcall(0.03, hotspots_visibility());
      </action>
  • Quote

    Pause on scroll out of view, Like is done with videos on Facebook, as you scroll down the web page.

    or like the brightcove player does when you scroll in and out of view -- http://docs.brightcove.com/en/video-cloud…-into-view.html

    I edited my original question.
    I would think stopping the krpano player on page scroll out of view would be an important feature already implemented.
    (Nothing more irritating then having to hit the pause button to get a video to shut up after you scrolled away down the page)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!