/** * @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 = { mp4: "https://s3.kikar.co.il/data/auto/flv/ei/1q24b3oc.m4v" }; var relatedData = [{ src: src, "contentMetadata": { "poster": [ "https://s3.kikar.co.il/data/auto/flv/thumb/io/kutncvrn.jpg", ] } }, { src: { hls: "https://cdna.streamgates.net/kikar_vod/588169.smil/playlist.m3u8" }, "contentMetadata": { "title": "איציק דדיה ויוסי לקס מבצעים: אבא איתי", "thumbnail": "https://s3.kikar.co.il/data/auto/flv/thumb/qb/wumdu7ep.jpg", "duration":"05:34", "poster": [ "https://s3.kikar.co.il/data/auto/flv/thumb/qb/wumdu7ep.jpg" ] } }, { src: { hls: "https://cdna.streamgates.net/kikar_vod/588154.smil/playlist.m3u8" }, "contentMetadata": { "title": "בני ברק: שוטרים תפסו אוהל בו תכננו חתונה", "thumbnail": "https://s3.kikar.co.il/data/auto/flv/thumb/pe/y406lup2.jpg", "duration":"00:50", "poster": [ "https://s3.kikar.co.il/data/auto/flv/thumb/pe/y406lup2.jpg" ] } }, { src: { hls: "https://cdna.streamgates.net/kikar_vod/588141.smil/playlist.m3u8" }, "contentMetadata": { "title": "הזעקה המצמררת של המגיד: שרו 'ק-ה אכסוף' - ונפטרו", "thumbnail": "https://s3.kikar.co.il/data/auto/flv/custom_thumb/uyavpjvm.jpg", "duration":"10:30", "poster": [ "https://s3.kikar.co.il/data/auto/flv/custom_thumb/uyavpjvm.jpg" ] } }, { src: { hls: "https://cdna.streamgates.net/kikar_vod/588140.smil/playlist.m3u8" }, "contentMetadata": { "title": "פרשת בא • הגאון רבי דוד לאו עם וורט על הפרשה", "thumbnail": "https://s3.kikar.co.il/data/auto/flv/custom_thumb/osqh6ci3.jpg", "duration":"09:07", "poster": [ "https://s3.kikar.co.il/data/auto/flv/custom_thumb/osqh6ci3.jpg" ] } }, { src: { hls: "https://cdna.streamgates.net/kikar_vod/588136.smil/playlist.m3u8" }, "contentMetadata": { "title": "באמצע הצומת: קטטה המונית ודקירות; צפו", "thumbnail": "https://s3.kikar.co.il/data/auto/flv/custom_thumb/e0g60i5n.jpg", "duration":"02:00", "poster": [ "https://s3.kikar.co.il/data/auto/flv/custom_thumb/e0g60i5n.jpg" ] } }, { src: { hls: "https://cdna.streamgates.net/kikar_vod/588119.smil/playlist.m3u8" }, "contentMetadata": { "title": "המופת של מרן הגרח קנייבסקי - והחנינה של טראמפ", "thumbnail": "https://s3.kikar.co.il/data/auto/flv/custom_thumb/5xslu947.jpg", "duration":"01:07", "poster": [ "https://s3.kikar.co.il/data/auto/flv/custom_thumb/5xslu947.jpg" ] } }, { src: { hls: "https://cdna.streamgates.net/kikar_vod/588118.smil/playlist.m3u8" }, "contentMetadata": { "title": "בני בגין מצטרף למפלגתו של גדעון סער", "thumbnail": "https://s3.kikar.co.il/data/auto/flv/thumb/ds/mreyxy4u.jpg", "duration":"01:27", "poster": [ "https://s3.kikar.co.il/data/auto/flv/thumb/ds/mreyxy4u.jpg" ] } }, { src: { hls: "https://cdna.streamgates.net/kikar_vod/588117.smil/playlist.m3u8" }, "contentMetadata": { "title": "הרב נפתלי וסרמן על פרשת בא • צפו", "thumbnail": "https://s3.kikar.co.il/data/auto/flv/custom_thumb/4m93r7lo.jpg", "duration":"02:57", "poster": [ "https://s3.kikar.co.il/data/auto/flv/custom_thumb/4m93r7lo.jpg" ] } }, { src: { hls: "https://cdna.streamgates.net/kikar_vod/588116.smil/playlist.m3u8" }, "contentMetadata": { "title": "המשטרה סגרה ישיבה בבני ברק; שניים נעצרו", "thumbnail": "https://s3.kikar.co.il/data/auto/flv/thumb/be/m6rhoajm.jpg", "duration":"00:34", "poster": [ "https://s3.kikar.co.il/data/auto/flv/thumb/be/m6rhoajm.jpg" ] } }, { src: { hls: "https://cdna.streamgates.net/kikar_vod/588110.smil/playlist.m3u8" }, "contentMetadata": { "title": "הפר בידוד, נתפס וטען: אני ספק חיוני; צפו", "thumbnail": "https://s3.kikar.co.il/data/auto/flv/custom_thumb/mylbqliu.jpg", "duration":"00:42", "poster": [ "https://s3.kikar.co.il/data/auto/flv/custom_thumb/mylbqliu.jpg" ] } }, ]; // we define our player streaming URLs and settings var settings = { width: 470, height: 351, muted: true, /*pip: true,*/ autoplay: true, sharing:true, sharingCode: '', sharingUrl: 'https://www.kikar.co.il/js/flowplayer/video.php?w=470&h=351&p=data%2Fauto%2Fflv%2Fthumb%2Fio%2Fkutncvrn.jpg&v=data%2Fauto%2Fflv%2Fei%2F1q24b3oc.m4v&v1=&a=1&rnd=0&885bb5a4', 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', relatedData: relatedData, relatedUpNextAutoplay: false, relatedUpNextOffset: 1, 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/flv/thumb/io/kutncvrn.jpg", ///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); })();