/** * @license Copyright (c) 2015-2019 Radiant Media Player * rmp-detachable-player | https://github.com/radiantmediaplayer/rmp-detachable-player */ (function () { 'use strict'; // reference to containers var playerId = 'rmpPlayer0'; var container = document.getElementById(playerId); var attachContainer = document.getElementById('attach-container0'); var detachContainer = document.getElementById('detach-container0'); if (!container || !attachContainer || !detachContainer) { return; } // our player instance var rmp = new RadiantMP(playerId); // player framework var rmpFW = rmp.getFramework(); var src = { hls: "https://cdna.streamgates.net/kikar_vod/588126.smil/playlist.m3u8" }; // we define our player streaming URLs and settings var settings = { width: 653, height: 367, muted: true, /*pip: true,*/ autoplay: true, sharing:true, sharingCode: '', sharingUrl: 'https://kikarhashabat.co.il/js/flowplayer/video.php?w=653&h=367&p=data%2Fauto%2Fnadm%2Fpz%2Fxi2w23my.png&v=data%2Fauto%2Fflv%2Fhs%2Fgj4otldq.m4v&v1=https%3A%2F%2Fcdna.streamgates.net%2Fkikar_vod%2F588126.smil%2Fplaylist.m3u8&a=1&rnd=0&708e7bfa', src: src, retryParameters: { manifest: { timeout: 10000, // timeout in ms, after which we abort a request maxTimeout: 64000, // maximum timeout in ms for all attempts before we fail maxAttempts: 3, // the maximum number of requests before we fail delay: 1000 // the base delay in ms between retries }, levels: { timeout: 10000, maxTimeout: 64000, maxAttempts: 5, delay: 1000 }, segment: { timeout: 20000, maxTimeout: 64000, maxAttempts: 7, delay: 1000 } }, speed: true, skin: 's3', licenseKey: 'd3NhYnFqZGpsZUAxNTgwNzY0', ads: true, // ad label that can be displayed within player UI while a linear ad is playing labels: { ads: { controlBarCustomMessage: 'Ads' } }, // We tell the player to use rmp-vast to load and parse VAST resources adParser: 'ima', // adOutStream: true, // skin: 'outstream', // we will autoplay our outstream ad unit when first in view so muted we must use // muted: true, adTagUrl: 'https://pubads.g.doubleclick.net/gampad/ads?sz=400x300&iu=/14723412/vast-desktop&impl=s&gdfp_req=1&env=vp&output=xml_vast2&unviewed_position_start=1&url=[referrer_url]&description_url=[description_url]&correlator=[timestamp]', adTagWaterfall: [ 'https://pubads.g.doubleclick.net/gampad/ads?sz=400x300&iu=/14723412/vast-desktop&impl=s&gdfp_req=1&env=vp&output=xml_vast2&unviewed_position_start=1&url=[referrer_url]&description_url=[description_url]&correlator=[timestamp]', ], // we use client-side waterfalling in this case (optional) poster: "https://s3.kikar.co.il/data/auto/nadm/pz/xi2w23my.png", ///autoHeightMode: true, detectAutoplayCapabilities: true, airplay: true, googleCast:true, gaTrackingId: 'UA-8661839-20', gaCategory: 'kikar', gaLabel: $(document).find("title").text(), gaEvents: ['context', 'ready', 'playerstart', 'error', 'adimpression', 'adloadererror', 'aderror'], preload: 'auto', }; // our app variables var debug = true; var _log = function(data) { if (window.console && window.console.log && data) { window.console.log(data); } }; var playerAttached = true; var viewablePreviousRatio = 0.5; var firstView = false; // function to run when the player should detach var _detachPlayer = function () { playerAttached = false; rmpFW.addClass(detachContainer, 'rmp-detach'); rmp.resize(); }; // function to run when the player should be attached to its original location var _attachPlayer = function () { playerAttached = true; rmpFW.removeClass(detachContainer, 'rmp-detach'); rmp.resize(); }; var _handleIntersect = function (entries) { entries.forEach(function (entry) { if (entry.intersectionRatio > viewablePreviousRatio) { if (debug) { _log('player comes into view'); } // we do not want to detach player before viewer has scrolled to it at least once if (!firstView) { firstView = true; // here we automatically play our outstream ad when player first comes into view rmp.play(); } if (!playerAttached) { _attachPlayer(); } } else { if (debug) { _log('player comes out of view'); } if (playerAttached && firstView) { _detachPlayer(); } } viewablePreviousRatio = entry.intersectionRatio; }); }; var _attachViewableObserver = function () { container.removeEventListener('ready', _attachViewableObserver); if (typeof window.IntersectionObserver !== 'undefined') { var options = { root: null, rootMargin: '0px', threshold: [0.5], }; var viewableObserver = new IntersectionObserver(_handleIntersect, options); viewableObserver.observe(attachContainer); } }; // when player is ready create IntersectionObserver container.addEventListener('ready', _attachViewableObserver); // we init the player rmp.init(settings); // Here we start our custom script var lastDifferential = 0; var uid = 25773809; // fullminutewatched event will be sent each time differential threshold has been reached (60000 ms === 1 minute) var sendingThreshold = 1000; // We will use an interval checking our differential threshold every 500 ms // console.log(0+'% watched',uid,'https://cdna.streamgates.net/kikar_vod/588126.smil/playlist.m3u8'); var url = "/mk_ajax_server.php?op=videoevent&uuid=25773809&vid=https://cdna.streamgates.net/kikar_vod/588126.smil/playlist.m3u8&p=0"; var xhttp = new XMLHttpRequest(); //xhttp.open("GET", url, true); //xhttp.send(); setInterval(function () { var percentViewed = rmp.getPercentViewed(); if (percentViewed > 0) { var diff = percentViewed - lastDifferential; if (diff >= 25) { lastDifferential = percentViewed; url = "/mk_ajax_server.php?op=videoevent&uuid=25773809&vid=https://cdna.streamgates.net/kikar_vod/588126.smil/playlist.m3u8&p="+percentViewed; //xhttp.open("GET", url, true); //xhttp.send(); } } }, 500); })();