// initialize jwplayer var playerInstance = jwplayer('player'); // player dom elements var playerContainerEl = document.querySelector('.player-container'); // returns video player position from top of document function getElementOffsetTop(el) { var boundingClientRect = el.getBoundingClientRect(); var bodyEl = document.body; var docEl = document.documentElement; var scrollTop = window.pageYOffset || docEl.scrollTop || bodyEl.scrollTop; var clientTop = docEl.clientTop || bodyEl.clientTop || 0; return Math.round(boundingClientRect.top + scrollTop - clientTop); } // returns the current y scroll position function getScrollTop() { var docEl = document.documentElement; return (window.pageYOffset || docEl.scrollTop) - (docEl.clientTop || 0); } // configure jwplayer instance playerInstance.setup({ autostart: true, playlist: 'https://cdn.jwplayer.com/v2/playlists/mYdavspX', primary: 'html5', setFullscreen: true, width: '100%' }); // when jwplayer instance is ready playerInstance.on('ready', function() { var config = playerInstance.getConfig(); var utils = playerInstance.utils; // get height of player element var playerHeight = config.containerHeight; // flag determining whether close has been clicked var closed = true; // CHANGED // flag determing whether player is playing var playing = false; // ADDED // eventhandler for when close button is being pressed document.getElementsByClassName('icon-close')[0].addEventListener('click', () => { closed = true; onScrollViewHandler(); }); playerInstance.on('play', function() { closed = false; playing = true; // ADDED }).on('pause', function () { playing = false; // ADDED }).on('adPlay', function() { closed = false; // ADDED playing = true; // ADDED }).on('adPause', function() { playing = false; // ADDED }); // get player element position from top of document var playerOffsetTop = getElementOffsetTop(playerContainerEl); // set player container to match height of actual video element playerContainerEl.style.height = playerHeight + 'px'; // below we handle window scroll event without killing performance function onScrollViewHandler() { var minimized = getScrollTop() >= playerOffsetTop; if (closed && minimized) { minimized = false; jwplayer().pause(); playing = false; // ADDED } else if (!minimized && !playing) { closed = true; // ADDED } utils.toggleClass(playerContainerEl, 'player-minimize', minimized); // update the player's size so the controls are adjusted playerInstance.resize(); } // namespace for whether or not we are waiting for setTimeout() to finish var isScrollTimeout = false; // window onscroll event handler window.onscroll = function() { // skip if we're waiting on a scroll update timeout to finish if (isScrollTimeout) return; // flag that a new timeout will begin isScrollTimeout = true; // otherwise, call scroll event view handler onScrollViewHandler(); // set new timeout setTimeout(function() { // reset timeout flag to false (no longer waiting) isScrollTimeout = false; }, 80); }; });

As we get geared up for Weekend 2 of the Call of Duty: Modern Warfare Beta, Activision and Infinity Ward have shared a new trailer highlighting the Weekend 2 Cross Play Beta.

The new trailer shows that the Cross Play Open Beta for all platforms will begin on Friday, September 20. The Early Access Cross Play Beta will begin on Thursday, Sept. 19 at 10AM PT.

Here’s the full schedule for Weekend 2:

PlayStation 4

  • Open Beta: September 19 at 10AM PT – September 23 at 10AM PT

Xbox One

  • Pre-Order Early Access: September 19 at 10AM PT – September 20 at 6PM PST
  • Open Beta: September 20 at 6PM PST – September 23 at 10AM PT

PC (Battle.net)

  • Pre-Order Early Access: September 19 at 10AM PT – September 20 at 6PM PST
  • Open Beta: September 20 at 6PM PST – September 23 at 10AM PT

And here’s the new trailer:

Get battle-ready in the Call of Duty®: Modern Warfare® Open Beta. Crossplay early access begins September 19th, with the open Beta kicking off on the 20th at 6PM PT.

Stay tuned for the latest updates on the Modern Warfare Beta.

comments below