Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const p2pconfig = {
- segments: {
- forwardSegmentCount: 60,
- swarmId: "qog604y9elih"
- },
- loader: {
- trackerAnnounce: 'wss://p2p.upstream.to:8433',
- cachedSegmentExpiration: 86400000,
- cachedSegmentsCount: 500,
- requiredSegmentsPriority: 2,
- p2pDownloadMaxPriority: 50,
- simultaneousP2PDownloads: 20,
- simultaneousHttpDownloads: 1,
- httpUseRanges: true,
- httpDownloadMaxPriority: 9,
- httpDownloadProbability: 0.06,
- httpDownloadProbabilityInterval: 1000,
- httpDownloadProbabilitySkipIfNoPeers: true,
- }
- };
- var engine = new p2pml.hlsjs.Engine(p2pconfig);
- var loaded_http = 0,
- loaded_p2p = 0;
- engine.on("peer_connect", peer => console.log("p2p_peer_connect", peer.id, peer.remoteAddress));
- engine.on("peer_close", peerId => console.log("p2p_peer_close", peerId));
- engine.on("segment_loaded", (segment, peerId) => console.log("p2p_segment_loaded from", peerId ? `peer ${peerId}` : "HTTP", segment.url));
- engine.on("piece_bytes_downloaded", function(method, size) {
- if (method == 'http') loaded_http += size;
- else loaded_p2p += size;
- console.log("piece_bytes_downloaded ", method, size, "Total HTTP:" + loaded_http, "P2P:" + loaded_p2p)
- });
- jwplayer("vplayer").setup({
- sources: [{
- 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"
- }],
- image: "https://s64.upstreamcdn.co/i/01/05153/qog604y9elih.jpg",
- width: "100%",
- height: "100%",
- stretching: "uniform",
- duration: "3341.13",
- preload: 'metadata',
- androidhls: "true",
- tracks: [{
- file: "/srt/empty.srt",
- label: "Upload captions",
- kind: "captions"
- }],
- captions: {
- userFontScale: 0.7,
- color: 'FFFFFF',
- backgroundColor: '#303030',
- fontFamily: "Verdana",
- backgroundOpacity: 90,
- fontOpacity: '100',
- },
- 'qualityLabels': {
- "1035": "Original"
- },
- abouttext: "",
- aboutlink: "https://upstream.to",
- cast: {},
- hlsjsConfig: {
- liveSyncDurationCount: 3,
- loader: engine.createLoaderClass(),
- }
- });
- var vvplay, vvad;
- var vastdone1 = 0,
- vastdone2 = 0;
- var player = jwplayer();
- var prevt = 0,
- tott = 0,
- v2done = 0,
- lastt = 0;
- $.ajaxSetup({
- headers: {
- 'Content-Cache': 'no-cache'
- }
- });
- player.on('time', function(x) {
- if (5 > 0 && x.position >= 5 && vvad != 1) {
- vvad = 1;
- $('div.video_ad_fadein').fadeIn('slow')
- }
- if (x.position >= lastt + 5 || x.position < lastt) {
- lastt = x.position;
- ls.set('ttqog604y9elih', Math.round(lastt), {
- ttl: 60 * 60 * 24 * 7
- })
- }
- });
- player.on('seek', function(x) {
- prevt = x.position
- });
- player.on('play', function(x) {
- doPlay(x)
- });
- player.on('complete', function() {
- $('div.video_ad').show();
- ls.remove('ttqog604y9elih')
- });
- player.on('pause', function(x) {});
- function doPlay(x) {
- $('div.video_ad').hide();
- $('#over_player_msg').hide();
- if (vvplay) return;
- vvplay = 1;
- adb = 0;
- if (window.cRAds === undefined) {
- adb = 1
- }
- $.get('/dl?op=view&file_code=qog604y9elih&hash=25767012-91-246-1707049534-e72048a2b27141ee8a410eba254facdf&embed=1&adb=' + adb, function(data) {
- $('#fviews').html(data)
- });
- var lastt = ls.get('ttqog604y9elih');
- if (lastt > 0) {
- jwplayer().seek(lastt)
- }
- }
- function set_audio_track() {
- var tracks = player.getAudioTracks(track_name);
- console.log(tracks);
- if (tracks.length > 1) {
- for (i = 0; i < tracks.length; i++) {
- if (tracks[i].name == track_name) {
- console.log('!!=' + i);
- player.setCurrentAudioTrack(i)
- }
- }
- }
- }
- player.on('ready', function() {
- player.on('captionsChanged', function(tr) {
- if (RegExp('empty').test(tr.tracks[tr.track].id)) {
- jwplayer().pause(true);
- jwplayer().setCurrentCaptions(0);
- openIframeOverlay('/?op=upload_srt&file_code=qog604y9elih')
- }
- });
- function openIframeOverlay(url) {
- var $dd = $("<div />").css({
- position: "absolute",
- width: "100%",
- height: "100%",
- left: 0,
- top: 0,
- zIndex: 1000000,
- background: "rgba(10%, 10%, 10%, 0.4)",
- "text-align": "center"
- });
- $("<iframe />").css({
- width: "60%",
- height: "60%",
- zIndex: 1000001,
- "margin-top": "50px"
- }).prop({
- 'src': url,
- 'frameborder': '0',
- 'scrolling': 'no'
- }).appendTo($dd);
- $dd.click(function() {
- $(this).remove();
- jwplayer().play()
- });
- $dd.appendTo($('#vplayer'))
- }
- });
- const iid = setInterval(() => {
- console.log(player.hls);
- if (player.hls && player.hls.config) {
- clearInterval(iid);
- p2pml.hlsjs.initHlsJsPlayer(player.hls)
- }
- }, 200);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement