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 getPluginWidth()
\r
24 function getPluginHeight()
\r
29 function getSliderWidth()
\r
31 return $("#nsSlider").width();
\r
34 function updateTime(afterSlider)
\r
36 var len = document.vlc.input.length;
\r
40 var val = 1.0 * $("#nsSlider").slider("option", "value");
\r
41 pos = val / (getSliderWidth() - 1);
\r
44 pos = document.vlc.input.position;
\r
45 var time = Math.round(pos * len);
\r
46 var crt_s = Math.floor(time / 1000 % 60);
\r
47 var crt_min = Math.floor((time / 1000) / 60);
\r
48 var tot_s = Math.floor(len / 1000 % 60);
\r
49 var tot_min = Math.floor((len / 1000) / 60);
\r
51 if(isNaN(crt_s)) crt_s = 0;
\r
52 if(isNaN(crt_min)) crt_min = 0;
\r
53 if(isNaN(tot_s)) tot_s = 0;
\r
54 if(isNaN(tot_min)) tot_min = 0;
\r
56 $("#nsTime").html("" + pad(crt_min, 2) + ":" + pad(crt_s, 2)
\r
57 + " / " + pad(tot_min, 2) + ":" + pad(tot_s, 2));
\r
62 var val = Math.round(document.vlc.input.position * (getSliderWidth() - 1));
\r
64 $("#nsSlider").slider({ value: val });
\r
68 timerHandle = setTimeout("update()", updateInterval);
\r
71 function displayNextSharePC(torrent, html5)
\r
75 document.write('<video src="'+torrent+'" controls="controls" width="800" height="600">');
\r
76 document.write(' Error: Your browser does not support HTML5!');
\r
77 document.write('</video>');
\r
78 document.write('<br /><br /><p><a href="' + window.location.href.replace('&html5=1', '') + '">');
\r
79 document.write('Play video using VLC with NextSharePC</a></p>');
\r
84 if (navigator.appName == "Netscape")
\r
86 document.write('<embed type="application/x-ns-stream"');
\r
87 document.write('name="vlc"');
\r
88 document.write('id="vlc"');
\r
89 document.write('autoplay="no" loop="no" width="');
\r
90 document.write('' + getPluginWidth());
\r
91 document.write('" height="');
\r
92 document.write('' + getPluginHeight());
\r
93 document.write('"');
\r
94 document.write('target="');
\r
95 document.write(torrent);
\r
96 document.write('" />');
\r
100 document.write('<object classid="clsid:1800B8AF-4E33-43C0-AFC7-894433C13538" ');
\r
101 document.write('codebase="http://trial.p2p-next.org/download/SwarmPlugin_IE_1.0.4.cab"');
\r
102 document.write('width="');
\r
103 document.write(getPluginWidth());
\r
104 document.write('" height="');
\r
105 document.write(getPluginHeight());
\r
106 document.write('" id="vlc" name="vlc" events="True" target="">');
\r
107 document.write('<param name="Src" value="');
\r
108 document.write(torrent);
\r
109 document.write('" />');
\r
110 document.write('<param name="ShowDisplay" value="True" />');
\r
111 document.write('<param name="Loop" value="False" />');
\r
112 document.write('<param name="AutoPlay" value="True" />');
\r
113 document.write('<param name="Toolbar" value="True" />');
\r
114 document.write('</object>');
\r
117 document.write('<table id="nsTable"><tr>'
\r
118 + '<td id="nsPlaybackCell"><input type=button value="Play" onClick="play();" />'
\r
119 + '<input type=button value="Pause" onClick="pause();" />'
\r
120 + '<input type=button value="Stop" onclick="stop();" /></td>'
\r
121 + '<td id="nsTimeCell"><span id="nsTime">-</span></td>'
\r
122 + '<td><div id="nsVol"></div></td>'
\r
123 + '<td><input type=button value="Fullscreen" onclick="fullscreen();" /></td></tr>'
\r
124 + '<tr><td colspan="4"><div id="nsSlider"></div></td></tr>'
\r
127 $("nsTable").css("width", getPluginWidth());
\r
129 document.write('<br /><p><a href="' + window.location.href + '&html5=1">');
\r
130 document.write('Play video using HTML5 with SwarmPlayer</a></p>');
\r
135 function onSliderStop(event, ui)
\r
137 var val = $("#nsSlider").slider("option", "value");
\r
138 var s = 1.0 * val / (getSliderWidth() - 1);
\r
140 //document.vlc.playlist.seek(s, false);
\r
141 //document.vlc.video.toggleFullscreen();
\r
145 document.vlc.input.position = 0.0000001;
\r
147 document.vlc.input.position = 0.9999999;
\r
149 document.vlc.input.position = s;
\r
152 alert(err.message + ": " + err.description);
\r
155 timerHandle = setTimeout("update()", updateInterval);
\r
158 function pad(number, length)
\r
160 var str = '' + number;
\r
161 while (str.length < length)
\r
169 function onSliderSlide(event, ui)
\r
173 clearTimeout(timerHandle);
\r
176 function onVolChange(event, ui)
\r
178 var val = $("#nsVol").slider("option", "value");
\r
180 document.vlc.audio.volume = val;
\r
183 $(document).ready(function()
\r
185 if(document.vlc == null)
\r
189 $("#nsSlider").slider({ animate: true });
\r
190 $("#nsSlider").slider({ min: 0 });
\r
191 $("#nsSlider").slider({ max: (getPluginWidth() - 1) });
\r
192 $("#nsSlider").slider({
\r
193 stop: onSliderStop,
\r
194 slide: onSliderSlide
\r
196 $("#nsSlider").css("width", getPluginWidth());// TODO
\r
197 $("#nsSlider").slider();
\r
200 $("#nsVol").slider({ animate: true });
\r
201 $("#nsVol").slider({ min: 0 });
\r
202 $("#nsVol").slider({ max: 200 });
\r
203 $("#nsVol").slider({ value: document.vlc.audio.volume });
\r
204 $("#nsVol").slider({
\r
205 change: onVolChange,
\r
207 $("#nsVol").css("width", 72);
\r
208 $("#nsVol").slider();
\r
210 timerHandle = setTimeout("update()", updateInterval);
\r
215 document.vlc.playlist.play();
\r
216 timerHandle = setTimeout("update()", updateInterval);
\r
221 document.vlc.playlist.togglePause();
\r
222 clearTimeout(timerHandle);
\r
227 document.vlc.playlist.stop();
\r
228 clearTimeout(timerHandle);
\r
231 function fullscreen()
\r
233 document.vlc.video.toggleFullscreen();
\r