A Pen by chandan688 on CodePen.
Created
March 27, 2022 01:11
-
-
Save HeNy007/de60a2400a53901fcd9f59e81682bdf0 to your computer and use it in GitHub Desktop.
clapper player FINAL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <head> | |
| </head> | |
| <body> | |
| <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clappr@latest/dist/clappr.min.js"></script> | |
| <script type="text/javascript" | |
| src="//cdn.jsdelivr.net/gh/clappr/clappr-level-selector-plugin@latest/dist/level-selector.min.js"></script> | |
| <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clappr-google-ima-html5-preroll-plugin@latest/dist/clappr-google-ima-html5-preroll-plugin.min.js"></script> | |
| <div id="player-container"><div id="player"></div></div> | |
| <div id="se_video" style="height: 56.25%; width: 100%;"></div> | |
| <script type="text/javascript"> | |
| playerElementID="#player"; | |
| var player = new Clappr.Player({ | |
| source: 'https://livestream.knowtable.xyz:5443/show/streams/Publictv_adaptive.m3u8', | |
| parentId: "#player", | |
| autoPlay: 'true', | |
| playInline: true, | |
| mute: true, | |
| width: '100%', | |
| height: '100%', | |
| parentId: playerElementID, | |
| plugins: {core: [LevelSelector,ClapprGoogleImaHtml5PrerollPlugin], playback: []}, | |
| googleImaHtml5PrerollPlugin: { | |
| tag: 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21849154601,21675075701/Ad.Plus-Video-Display&description_url=publictv.in&env=vp&impl=s&correlator=&tfcd=0&npa=0&ad_type=audio_video&gdfp_req=1&vpa=1&vpmute=1&output=vast&sz=400x300%7C640x480&unviewed_position_start=1', | |
| vpaid: 0, | |
| autostart: false, | |
| events: { | |
| content_resume_requested: function() { console.log('content_resume_requested') }, | |
| content_pause_requested: function() { console.log('content_pause_requested') }, | |
| loaded: function() { console.log('loaded') }, | |
| click: function() { console.log('click') }, | |
| impression: function() { console.log('impression') }, | |
| started: function() { console.log('started') }, | |
| first_quartile: function() { console.log('first_quartile') }, | |
| midpoint: function() { console.log('midpoint') }, | |
| third_quartile: function() { console.log('third_quartile') }, | |
| complete: function() { console.log('complete') }, | |
| paused: function() { console.log('paused') }, | |
| resumed: function() { console.log('resumed') }, | |
| skipped: function() { console.log('skipped') }, | |
| user_close: function() { console.log('user_close') }, | |
| ad_error: function(e) { console.log('ad_error: ' + e.getError()) }, // AdErrorEvent | |
| error: function(e) { console.log('error', e) }, | |
| } | |
| }, | |
| levelSelectorConfig: { | |
| title: 'Quality', | |
| labels: { | |
| 2: 'High', // 1500kbps | |
| 1: 'Med', // 240kbps | |
| 0: 'Low', // 120kbps | |
| }, | |
| labelCallback: function(playbackLevel, customLabel) { | |
| return customLabel/* + playbackLevel.level.height+'p'*/; // High 720p | |
| } | |
| }, | |
| }); | |
| function resizePlayer(){ | |
| var aspectRatio = 9/16, | |
| newWidth = document.getElementById('se_video').parentElement.offsetWidth - 42, | |
| newHeight = 2 * Math.round(newWidth * aspectRatio/2); | |
| player.resize({width: newWidth, height: newHeight}); | |
| } | |
| window.onload = (function(){ | |
| resizePlayer(); | |
| var addEventListener = (function() { | |
| if(document.addEventListener) { | |
| return function(element, event, handler) { | |
| element.addEventListener(event, handler, false); | |
| }; | |
| } else { | |
| return function(element, event, handler) { | |
| element.attachEvent('on' + event, handler); | |
| }; | |
| } | |
| }()); | |
| addEventListener(window, 'resize', resizePlayer); | |
| }); | |
| </script> | |
| </body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment