1 // NextSharePC plugin controls
\r
2 // Author: Calin-Andrei Burloiu, calin.burloiu@gmail.com
\r
5 updateInterval = 500;
\r
7 function getURLParam( name )
\r
9 name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
\r
10 var regexS = "[\\?&]"+name+"=([^&#]*)";
\r
11 var regex = new RegExp( regexS );
\r
12 var results = regex.exec( window.location.href );
\r
13 if( results == null )
\r
19 function pad(number, length)
\r
21 var str = '' + number;
\r
22 while (str.length < length)
\r
30 function getPluginWidth()
\r
35 function getPluginHeight()
\r
40 function getSliderWidth()
\r
42 return $("#nsSlider").width();
\r
45 function updateTime(afterSlider)
\r
47 var len = document.vlc.input.length;
\r
51 var val = 1.0 * $("#nsSlider").slider("option", "value");
\r
52 pos = val / (getSliderWidth() - 1);
\r
55 pos = document.vlc.input.position;
\r
56 var time = Math.round(pos * len);
\r
57 var crt_s = Math.floor(time / 1000 % 60);
\r
58 var crt_min = Math.floor((time / 1000) / 60);
\r
59 var tot_s = Math.floor(len / 1000 % 60);
\r
60 var tot_min = Math.floor((len / 1000) / 60);
\r
62 if(isNaN(crt_s)) crt_s = 0;
\r
63 if(isNaN(crt_min)) crt_min = 0;
\r
64 if(isNaN(tot_s)) tot_s = 0;
\r
65 if(isNaN(tot_min)) tot_min = 0;
\r
67 $("#nsTime").html("" + pad(crt_min, 2) + ":" + pad(crt_s, 2)
\r
68 + " / " + pad(tot_min, 2) + ":" + pad(tot_s, 2));
\r
73 var val = Math.round(document.vlc.input.position * (getSliderWidth() - 1));
\r
75 $("#nsSlider").slider({ value: val });
\r
79 timerHandle = setTimeout("update()", updateInterval);
\r
82 function displayNextSharePC(torrent)
\r
84 //document.write('popârțac');
\r
87 if (navigator.appName == "Netscape")
\r
89 document.write('<embed type="application/x-ns-stream"');
\r
90 document.write('name="vlc"');
\r
91 document.write('id="vlc"');
\r
92 document.write('autoplay="no" loop="no" width="');
\r
93 document.write('' + getPluginWidth());
\r
94 document.write('" height="');
\r
95 document.write('' + getPluginHeight());
\r
96 document.write('"');
\r
97 document.write('target="');
\r
98 document.write(torrent);
\r
99 document.write('" />');
\r
103 document.write('<object classid="clsid:1800B8AF-4E33-43C0-AFC7-894433C13538" ');
\r
104 document.write('codebase="http://trial.p2p-next.org/download/SwarmPlugin_IE_1.0.4.cab"');
\r
105 document.write('width="');
\r
106 document.write(getPluginWidth());
\r
107 document.write('" height="');
\r
108 document.write(getPluginHeight());
\r
109 document.write('" id="vlc" name="vlc" events="True" target="">');
\r
110 document.write('<param name="Src" value="');
\r
111 document.write(torrent);
\r
112 document.write('" />');
\r
113 document.write('<param name="ShowDisplay" value="True" />');
\r
114 document.write('<param name="Loop" value="False" />');
\r
115 document.write('<param name="AutoPlay" value="True" />');
\r
116 document.write('<param name="Toolbar" value="True" />');
\r
117 document.write('</object>');
\r
120 document.write('<table id="nsTable"><tr>'
\r
121 + '<td id="nsPlaybackCell"><input type=button value="Play" onClick="play();" />'
\r
122 + '<input type=button value="Pause" onClick="pause();" />'
\r
123 + '<input type=button value="Stop" onclick="stop();" /></td>'
\r
124 + '<td id="nsTimeCell"><span id="nsTime">-</span></td>'
\r
125 + '<td><div id="nsVol"></div></td>'
\r
126 + '<td><input type=button value="Fullscreen" onclick="fullscreen();" /></td></tr>'
\r
127 + '<tr><td colspan="4"><div id="nsSlider"></div></td></tr>'
\r
133 function onSliderStop(event, ui)
\r
135 var val = $("#nsSlider").slider("option", "value");
\r
136 var s = 1.0 * val / (getSliderWidth() - 1);
\r
138 //document.vlc.playlist.seek(s, false);
\r
139 //document.vlc.video.toggleFullscreen();
\r
143 document.vlc.input.position = 0.0000001;
\r
145 document.vlc.input.position = 0.9999999;
\r
147 document.vlc.input.position = s;
\r
150 alert(err.message + ": " + err.description);
\r
153 timerHandle = setTimeout("update()", updateInterval);
\r
156 function onSliderSlide(event, ui)
\r
160 clearTimeout(timerHandle);
\r
163 function onVolChange(event, ui)
\r
165 var val = $("#nsVol").slider("option", "value");
\r
167 document.vlc.audio.volume = val;
\r
170 function loadControls()
\r
172 if(document.vlc == null)
\r
175 $("nsTable").css("width", getPluginWidth());
\r
178 $("#nsSlider").slider({ animate: true });
\r
179 $("#nsSlider").slider({ min: 0 });
\r
180 $("#nsSlider").slider({ max: (getPluginWidth() - 1) });
\r
181 $("#nsSlider").slider({
\r
182 stop: onSliderStop,
\r
183 slide: onSliderSlide
\r
185 $("#nsSlider").css("width", getPluginWidth());// TODO
\r
186 $("#nsSlider").slider();
\r
189 $("#nsVol").slider({ animate: true });
\r
190 $("#nsVol").slider({ min: 0 });
\r
191 $("#nsVol").slider({ max: 200 });
\r
192 $("#nsVol").slider({ value: document.vlc.audio.volume });
\r
193 $("#nsVol").slider({
\r
194 change: onVolChange,
\r
196 $("#nsVol").css("width", 72);
\r
197 $("#nsVol").slider();
\r
199 timerHandle = setTimeout("update()", updateInterval);
\r
204 document.vlc.playlist.play();
\r
205 timerHandle = setTimeout("update()", updateInterval);
\r
210 document.vlc.playlist.togglePause();
\r
211 clearTimeout(timerHandle);
\r
216 document.vlc.playlist.stop();
\r
217 clearTimeout(timerHandle);
\r
220 function fullscreen()
\r
222 document.vlc.video.toggleFullscreen();
\r