Advertisement
Guest User

Untitled

a guest
Feb 4th, 2024
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 5.21 KB | Source Code | 0 0
  1. const p2pconfig = {
  2.     segments: {
  3.         forwardSegmentCount: 60,
  4.         swarmId: "qog604y9elih"
  5.     },
  6.     loader: {
  7.         trackerAnnounce: 'wss://p2p.upstream.to:8433',
  8.         cachedSegmentExpiration: 86400000,
  9.         cachedSegmentsCount: 500,
  10.         requiredSegmentsPriority: 2,
  11.         p2pDownloadMaxPriority: 50,
  12.         simultaneousP2PDownloads: 20,
  13.         simultaneousHttpDownloads: 1,
  14.         httpUseRanges: true,
  15.         httpDownloadMaxPriority: 9,
  16.         httpDownloadProbability: 0.06,
  17.         httpDownloadProbabilityInterval: 1000,
  18.         httpDownloadProbabilitySkipIfNoPeers: true,
  19.     }
  20. };
  21. var engine = new p2pml.hlsjs.Engine(p2pconfig);
  22. var loaded_http = 0,
  23.     loaded_p2p = 0;
  24. engine.on("peer_connect", peer => console.log("p2p_peer_connect", peer.id, peer.remoteAddress));
  25. engine.on("peer_close", peerId => console.log("p2p_peer_close", peerId));
  26. engine.on("segment_loaded", (segment, peerId) => console.log("p2p_segment_loaded from", peerId ? `peer ${peerId}` : "HTTP", segment.url));
  27. engine.on("piece_bytes_downloaded", function(method, size) {
  28.     if (method == 'http') loaded_http += size;
  29.     else loaded_p2p += size;
  30.     console.log("piece_bytes_downloaded ", method, size, "Total HTTP:" + loaded_http, "P2P:" + loaded_p2p)
  31. });
  32. jwplayer("vplayer").setup({
  33.     sources: [{
  34.         file: "https://s64.upstreamcdn.co/hls2/01/05153/qog604y9elih_o/master.m3u8?t=yM4GrqF5oZfvr7ZHnPzowVWCvE05Y3FL0Ic1KhGXOnA&s=1707049534&e=10800&f=25767012&i=0.0&sp=0"
  35.     }],
  36.     image: "https://s64.upstreamcdn.co/i/01/05153/qog604y9elih.jpg",
  37.     width: "100%",
  38.     height: "100%",
  39.     stretching: "uniform",
  40.     duration: "3341.13",
  41.     preload: 'metadata',
  42.     androidhls: "true",
  43.     tracks: [{
  44.         file: "/srt/empty.srt",
  45.         label: "Upload captions",
  46.         kind: "captions"
  47.     }],
  48.     captions: {
  49.         userFontScale: 0.7,
  50.         color: 'FFFFFF',
  51.         backgroundColor: '#303030',
  52.         fontFamily: "Verdana",
  53.         backgroundOpacity: 90,
  54.         fontOpacity: '100',
  55.     },
  56.     'qualityLabels': {
  57.         "1035": "Original"
  58.     },
  59.     abouttext: "",
  60.     aboutlink: "https://upstream.to",
  61.     cast: {},
  62.     hlsjsConfig: {
  63.         liveSyncDurationCount: 3,
  64.         loader: engine.createLoaderClass(),
  65.     }
  66. });
  67. var vvplay, vvad;
  68. var vastdone1 = 0,
  69.     vastdone2 = 0;
  70. var player = jwplayer();
  71. var prevt = 0,
  72.     tott = 0,
  73.     v2done = 0,
  74.     lastt = 0;
  75. $.ajaxSetup({
  76.     headers: {
  77.         'Content-Cache': 'no-cache'
  78.     }
  79. });
  80. player.on('time', function(x) {
  81.     if (5 > 0 && x.position >= 5 && vvad != 1) {
  82.         vvad = 1;
  83.         $('div.video_ad_fadein').fadeIn('slow')
  84.     }
  85.     if (x.position >= lastt + 5 || x.position < lastt) {
  86.         lastt = x.position;
  87.         ls.set('ttqog604y9elih', Math.round(lastt), {
  88.             ttl: 60 * 60 * 24 * 7
  89.         })
  90.     }
  91. });
  92. player.on('seek', function(x) {
  93.     prevt = x.position
  94. });
  95. player.on('play', function(x) {
  96.     doPlay(x)
  97. });
  98. player.on('complete', function() {
  99.     $('div.video_ad').show();
  100.     ls.remove('ttqog604y9elih')
  101. });
  102. player.on('pause', function(x) {});
  103.  
  104. function doPlay(x) {
  105.     $('div.video_ad').hide();
  106.     $('#over_player_msg').hide();
  107.     if (vvplay) return;
  108.     vvplay = 1;
  109.     adb = 0;
  110.     if (window.cRAds === undefined) {
  111.         adb = 1
  112.     }
  113.     $.get('/dl?op=view&file_code=qog604y9elih&hash=25767012-91-246-1707049534-e72048a2b27141ee8a410eba254facdf&embed=1&adb=' + adb, function(data) {
  114.         $('#fviews').html(data)
  115.     });
  116.     var lastt = ls.get('ttqog604y9elih');
  117.     if (lastt > 0) {
  118.         jwplayer().seek(lastt)
  119.     }
  120. }
  121.  
  122. function set_audio_track() {
  123.     var tracks = player.getAudioTracks(track_name);
  124.     console.log(tracks);
  125.     if (tracks.length > 1) {
  126.         for (i = 0; i < tracks.length; i++) {
  127.             if (tracks[i].name == track_name) {
  128.                 console.log('!!=' + i);
  129.                 player.setCurrentAudioTrack(i)
  130.             }
  131.         }
  132.     }
  133. }
  134. player.on('ready', function() {
  135.     player.on('captionsChanged', function(tr) {
  136.         if (RegExp('empty').test(tr.tracks[tr.track].id)) {
  137.             jwplayer().pause(true);
  138.             jwplayer().setCurrentCaptions(0);
  139.             openIframeOverlay('/?op=upload_srt&file_code=qog604y9elih')
  140.         }
  141.     });
  142.  
  143.     function openIframeOverlay(url) {
  144.         var $dd = $("<div />").css({
  145.             position: "absolute",
  146.             width: "100%",
  147.             height: "100%",
  148.             left: 0,
  149.             top: 0,
  150.             zIndex: 1000000,
  151.             background: "rgba(10%, 10%, 10%, 0.4)",
  152.             "text-align": "center"
  153.         });
  154.         $("<iframe />").css({
  155.             width: "60%",
  156.             height: "60%",
  157.             zIndex: 1000001,
  158.             "margin-top": "50px"
  159.         }).prop({
  160.             'src': url,
  161.             'frameborder': '0',
  162.             'scrolling': 'no'
  163.         }).appendTo($dd);
  164.         $dd.click(function() {
  165.             $(this).remove();
  166.             jwplayer().play()
  167.         });
  168.         $dd.appendTo($('#vplayer'))
  169.     }
  170. });
  171. const iid = setInterval(() => {
  172.     console.log(player.hls);
  173.     if (player.hls && player.hls.config) {
  174.         clearInterval(iid);
  175.         p2pml.hlsjs.initHlsJsPlayer(player.hls)
  176.     }
  177. }, 200);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement