PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.1.8
WpStream – Live Streaming, Video on Demand, Pay Per View v3.1.8
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
wpstream / public / js / wpstream-player.js

wpstream-player.js in WpStream – Live Streaming, Video on Demand, Pay Per View 3.1.8, at public/js/wpstream-player.js

112 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 * player,'.$live_event_uri_final.','.$live_conect_views.'
6 */
7
8 window.WebSocket = window.WebSocket || window.MozWebSocket;
9 if (!window.WebSocket) {
10 console.log("Sorry, but your browser doesnt support WebSockets");
11 }
12
13
14 var timeQueue;
15
16 function wpstream_player_initialize(now,live_event_uri_final,live_conect_views){
17
18 var player = videojs('wpstream-video'+now,{
19 html5: {
20 hls: {
21 bandwidth: 500000,
22 useBandwidthFromLocalStorage: true,
23 overrideNative: !videojs.browser.IS_SAFARI,
24 smoothQualityChange: true
25 }
26 },
27 errorDisplay: false,
28 autoplay:true,
29 preload:"auto"
30 });
31
32
33 wpstream_player_load(player,live_event_uri_final,live_conect_views);
34
35 timeQueue = [];
36 setInterval(function(){
37 timeQueue.push(player.currentTime());
38 if (timeQueue.length > 30){
39 timeQueue.shift();
40 if (timeQueue[0] == timeQueue[timeQueue.length -1]){
41
42 if (!player.paused() || player.currentTime() == 0){
43 timeQueue = [];
44 try{
45 player.currentTime(0);
46 }catch(err){
47
48 }
49 wpstream_player_load(player,live_event_uri_final,live_conect_views);
50 }
51
52 }
53 }
54 }, 1000);
55
56
57 }
58
59
60
61
62
63 function wpstream_player_load(player,live_event_uri_final,live_conect_views){
64 player.src({
65 src: live_event_uri_final,
66 type: "application/x-mpegURL"
67 });
68 player.play();
69
70 }
71
72
73
74
75
76 function wpstream_count_connect_plugin(player,live_conect_views){
77
78 console.log("connecting counter...");
79 var connection = new WebSocket("wss://"+live_conect_views+":10111");
80 connection.onopen = function () {
81 console.log("connected.")
82 };
83
84 connection.onclose = function(){
85 console.log("closed. reconnecting...");
86 setTimeout(function(){ wpstream_count_connect_plugin(live_conect_views) }, 5 * 1000);
87 }
88
89 connection.onerror = function (error) {
90 console.log("onerror: ", error);
91 };
92
93 connection.onmessage = function (message) {
94 try {
95 var json = JSON.parse(message.data);
96 } catch (e) {
97 console.log("Invalid JSON: ", message.data);
98 return;
99 }
100 if (json.type === "viewerCount") {
101 count = json.data;
102 console.log("viewers: " + count)
103 var view_box=jQuery("#"+player+" .wpestream_live_counting");
104 view_box.css("background-color","#c91d1d");
105 view_box.html( count + " Viewers");
106
107 } else {
108 console.log("Unknown type:", json);
109 }
110 };
111 }
112