• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt/router/lighttpd-1.4.39/external_file/js_src/
1var m = new lang();
2var g_storage = new myStorage();
3var g_this_video = "";
4var g_this_video_name = "";
5var g_this_video_hash = "";
6var g_play_id = -1;
7var g_subtitle_timer = 0;
8var prevState = 0;
9var liveFeedText = ["Playing", "((Playing))", "(( Playing ))", "((  Playing  ))"];
10var liveFeedRoll = 0;
11var g_isIE = false;
12var g_video_status = "";
13/*
14UTF8 = {
15    encode: function(s){
16        for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
17            s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
18        );
19        return s.join("");
20    },
21    decode: function(s){
22        for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
23            ((a = s[i][c](0)) & 0x80) &&
24            (s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
25            o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
26        );
27        return s.join("");
28    }
29};
30
31function getUrlVars(){
32	var vars = [], hash;
33    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
34    for(var i = 0; i < hashes.length; i++)
35    {
36        hash = hashes[i].split('=');
37        vars.push(hash[0]);
38        vars[hash[0]] = hash[1];
39    }
40    return vars;
41}
42*/
43function detectVLCInstalled(){
44	var val = navigator.userAgent.toLowerCase();
45
46	var vlcInstalled= false;
47
48	if(g_isIE){
49		var vlcObj = null;
50		try {
51			vlcObj = new ActiveXObject("VideoLAN.Vlcplugin");
52		}
53		catch (e) {
54			var msg= "An exception occurred while trying to create the object VideoLAN.VLCPlugin.1:\n";
55		  	for (p in e)
56		  		msg+= "e."+p+"= " + e[p] + "\n";
57		  	//window.alert (msg);
58		}
59		if( null != vlcObj )
60   			vlcInstalled = true;
61	}
62	else{
63		if( navigator.plugins && navigator.plugins.length ) {
64	  		for( var i=0; i < navigator.plugins.length; i++ ) {
65	    		var plugin = navigator.plugins[i];
66	   			if( plugin.name.indexOf("VideoLAN") > -1
67	    			|| plugin.name.indexOf("VLC") > -1) {
68	      			vlcInstalled = true;
69	     		}
70	   		}
71	 	}
72	}
73
74	return vlcInstalled;
75}
76
77function getInternetExplorerVersion(){
78   	var rv = -1; // Return value assumes failure.
79	if (navigator.appName == 'Microsoft Internet Explorer'){
80	var ua = navigator.userAgent;
81      	var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
82      	if (re.exec(ua) != null)
83        	rv = parseFloat( RegExp.$1 );
84   }
85   return rv;
86}
87
88function closeWindow(){
89	parent.closeJqmWindow(0);
90}
91
92$(document).keydown(function(e) {
93	if (e.keyCode == 27) return false;
94});
95
96function init(){
97	setTimeout(function(){
98		createVLC();
99	},500);
100	/*
101	document.write("<body width='100%' height='100%' style='margin:0px;padding:0px;background-color:#000;text-align:center'>");
102	document.write("<span style='color:#fff;font-size:20px'>Loading....</span>");
103	document.write("</body>");
104
105	var this_query_title = getUrlVars()["t"];
106	if( typeof this_query_title != undefined && this_query_title != "" ){
107
108		$.getJSON( 'http://imdbapi.org/?title=' + this_query_title + '&type=json',
109	    	//options,
110  	        function(data) {
111
112				if(data[0]==undefined){
113					setTimeout(function(){
114						createVLC();
115					},500);
116					return;
117				}
118
119				var poster_image = data[0]['poster'];
120				var imdb_url = data[0]['imdb_url'];
121				var overview_html = "";
122
123				//overview_html += "<body>";
124				overview_html += "<div class='movie_overview'>";
125				overview_html += "<table cellspacing='0' cellpadding='0' border='0'>";
126				overview_html += "<tbody>";
127				overview_html += "<tr><td rowspan='2' class='img_primary' style='padding: 0 14px 0 0;'>";
128				overview_html += "<div width='100%'><img src='" + poster_image + "'><div>";
129				overview_html += "</td>";
130				overview_html += "<td class='overview'>";
131
132				overview_html += "<form class='x-form'>";
133
134				overview_html += '<div class="x-panel x-panel-noborder">';
135				overview_html += '<div class="x-panel-bwrap">';
136				overview_html += '<div class="x-panel-body x-panel-body-noheader x-panel-body-noborder x-table-layout-ct"><table class="x-table-layout" cellspacing="0">';
137				overview_html += '<tbody><tr><td class="x-table-layout-cell syno-vs-meta-title">';
138				overview_html += '<div class="x-form-display-field x-form-display-title-field">Batman Begins - Evil Fears The Knight</div>';
139				overview_html += '</td></tr></tbody></table></div></div></div>';
140
141				overview_html += "<div class='x-form-item'>";
142				overview_html += "<label class='x-form-item-label'>������</label>";
143				overview_html += "<div>";
144				overview_html += '<div class="x-form-display-field">';
145				overview_html += '<span class="syno-vs-field-48" id="ext-gen1139">Action film</span>, <span class="syno-vs-field-49" id="ext-gen1140">Drama</span>, <span class="syno-vs-field-50" id="ext-gen1141">Crime Fiction</span>, <span class="syno-vs-field-51" id="ext-gen1142">Adventure film</span>';
146				overview_html += '</div>';
147				overview_html += "</div>";
148				overview_html += "</div>";
149
150				overview_html += "<div class='x-form-item'>";
151				overview_html += "<label class='x-form-item-label'>������</label>";
152				overview_html += "<div>";
153				overview_html += '<div class="x-form-display-field">';
154				overview_html +=  data[0]['year'];
155				overview_html += "</div>";
156				overview_html += "</div>";
157				overview_html += "</div>";
158
159				overview_html += "<div class='x-form-item'>";
160				overview_html += "<label class='x-form-item-label'>������������</label>";
161				overview_html += "<div>";
162				overview_html += '<div class="x-form-display-field">';
163				overview_html +=  "<a class='allowDefCtxMenu' href='" + imdb_url + "' target='_blank'>IMDb</a>";
164				overview_html += "</div>";
165				overview_html += "</div>";
166				overview_html += "</div>";
167
168				overview_html += "<div class='x-form-item' style='padding-top:15px;'>";
169				overview_html += "<div>";
170				overview_html += '<div class="x-form-display-field">';
171				overview_html += data[0]['plot_simple'];
172				overview_html += "</div>";
173				overview_html += "</div>";
174				overview_html += "</div>";
175
176				overview_html += "</form>";
177
178				//overview_html += "<table cellspacing='0' cellpadding='0' border='0'>";
179				//overview_html += "<tbody>";
180				//overview_html += "<tr><td class='a1'>������</td><td class='a2'></td></tr>";
181				//overview_html += "<tr><td class='a1'>������</td><td class='a2'>" + data[0]['year'] + "</td></tr>";
182				//overview_html += "<tr><td class='a1'>������������</td><td class='a2'><a href='" + imdb_url + "' target='_blank'>IMDb</a></td></tr>";
183				//overview_html += "<tr><td class='a1'>������</td><td class='a2'>" + data[0]['plot_simple'] + "</td></tr>";
184				//overview_html += "</tbody>";
185				//overview_html += "</table>";
186
187				overview_html += "</td>";
188				overview_html += "</tr>";
189				overview_html += "</tbody>";
190				overview_html += "</table>";
191
192				overview_html += "<button id='btnClose' style='position: relative;float:right;right:5px;' onclick='parent.closeJqmWindow(0);'>close</button>";
193				overview_html += "<button id='btnPlay' style='position: relative;float:right;right:25px;' onclick='createVLC();'>play</button>";
194				overview_html += "</div>";
195				//overview_html += "</body>";
196
197				$("body").empty();
198				$(overview_html).appendTo($("body"));
199			}
200		);
201	}
202	else{
203		setTimeout(function(){
204			createVLC();
205		},500);
206	}
207	*/
208}
209
210function getVLC(name){
211	return document.getElementById(name);
212}
213
214function monitor(){
215    var vlc = getVLC("vlc");
216    var newState = 0;
217
218    if( vlc ){
219    	newState = vlc.input.state;
220    }
221
222    if( prevState != newState ){
223        if( newState == 0 ){
224            // current media has stopped
225            onEnd();
226        }
227        else if( newState == 1 ){
228            // current media is openning/connecting
229            onOpen();
230        }
231        else if( newState == 2 ){
232            // current media is buffering data
233            onBuffer();
234        }
235        else if( newState == 3 ){
236            // current media is now playing
237            onPlaying();
238        }
239        else if( newState == 4 ){
240            // current media is now paused
241            onPause();
242        }
243        else if( newState == 5 ){
244            // current media has stopped
245            onStop();
246        }
247        else if( newState == 6 ){
248            // current media has ended
249            onEnd();
250        }
251        else if( newState == 7 ){
252            // current media encountered error
253            onError();
254        }
255        prevState = newState;
256    }
257    else if( newState == 3 ){
258        // current media is playing
259        onPlaying();
260    }
261}
262
263function formatTime(timeVal){
264    if( typeof timeVal != 'number' )
265        return "-:--:--";
266
267    var timeHour = Math.round(timeVal / 1000);
268    var timeSec = timeHour % 60;
269    if( timeSec < 10 )
270        timeSec = '0'+timeSec;
271    timeHour = (timeHour - timeSec)/60;
272    var timeMin = timeHour % 60;
273    if( timeMin < 10 )
274        timeMin = '0'+timeMin;
275    timeHour = (timeHour - timeMin)/60;
276    if( timeHour > 0 )
277        return timeHour+":"+timeMin+":"+timeSec;
278    else
279        return timeMin+":"+timeSec;
280}
281
282function doPlay(){
283	var vlc = getVLC("vlc");
284
285  	if( vlc && g_play_id >= 0){
286
287		//vlc.playlist.playItem(g_play_id);
288		if(g_video_status == "pause"){
289			//vlc.input.time = parseInt(g_storage.getl(g_this_video_hash));
290			vlc.playlist.play();
291		}
292		else{
293			vlc.playlist.playItem(g_play_id);
294		}
295
296		$(".play").css("display", "none");
297		$(".pause").css("display", "block");
298	}
299}
300
301function doPause(){
302	var vlc = getVLC("vlc");
303
304  	if( vlc){
305  		if(g_isIE)
306			vlc.playlist.stop();
307		else
308			vlc.playlist.pause();
309
310		$(".play").css("display", "block");
311		$(".pause").css("display", "none");
312	}
313}
314
315function doStop(){
316	var vlc = getVLC("vlc");
317
318  	if( vlc ){
319  		vlc.playlist.stop();
320
321		$(".play").css("display", "block");
322		$(".pause").css("display", "none");
323
324  		onStop();
325	}
326}
327
328function onOpen(){
329	g_video_status = "open";
330	document.getElementById("info").innerHTML = "Opening...";
331}
332
333function onEnd(){
334	g_video_status = "stop";
335	document.getElementById("info").innerHTML = "End...";
336}
337
338function onBuffer(){
339	document.getElementById("info").innerHTML = "Buffering...";
340}
341
342function onPause(){
343	g_video_status = "pause";
344	document.getElementById("info").innerHTML = "Paused...";
345}
346
347function onStop(){
348	g_video_status = "stop";
349	document.getElementById("info").innerHTML = "-:--:--/-:--:--";
350}
351
352function onError(){
353	g_video_status = "error";
354	document.getElementById("info").innerHTML = "Error...";
355}
356
357function record_playtime(){
358	var vlc = getVLC("vlc");
359	if(vlc){
360		g_storage.setl(g_this_video_hash, vlc.input.time);
361	}
362}
363
364function onPlaying(){
365	var vlc = getVLC("vlc");
366  	var info = document.getElementById("info");
367
368  	if( vlc ){
369  		var mediaLen = vlc.input.length;
370    	if( mediaLen > 0 ){
371			$(".currTime").text(formatTime(vlc.input.time));
372			$(".totalTime").text(formatTime(mediaLen));
373    		info.innerHTML = formatTime(vlc.input.time)+"/"+formatTime(mediaLen);
374
375			var pos = (vlc.input.time/mediaLen)*$(".playbar .slider-tracker").width();
376			$(".playbar .slider-thumb").css("left", pos);
377			$(".playbar .slider-progress").css("width", pos);
378    	}
379    	else{
380    		// non-seekable "live" media
381      		liveFeedRoll = liveFeedRoll & 3;
382      		info.innerHTML = liveFeedText[liveFeedRoll++];
383    	}
384  	}
385
386	record_playtime();
387}
388
389function doMarqueeOption(option, value)
390{
391    var vlc = getVLC("vlc");
392    val = parseInt(value);
393
394    if( vlc )
395    {
396        if (option == 1)
397            vlc.video.marquee.color = val;
398        if (option == 2)
399            vlc.video.marquee.opacity = val;
400        if (option == 3)
401            vlc.video.marquee.position = value;
402        if (option == 4)
403            vlc.video.marquee.refresh = val;
404        if (option == 5)
405            vlc.video.marquee.size = val;
406        if (option == 6)
407            vlc.video.marquee.text = value;
408        if (option == 7)
409            vlc.video.marquee.timeout = val;
410        if (option == 8)
411            vlc.video.marquee.x = val;
412        if (option == 9)
413            vlc.video.marquee.y = val;
414    }
415}
416
417function doAspectRatio(){
418    var vlc = getVLC("vlc");
419
420    if( vlc )
421        vlc.video.aspectRatio = $("#select_aspect").val();
422}
423
424function play_subtitle(){
425	$('.srt').each(function() {
426		var vlc = getVLC("vlc");
427		var toSeconds = function(t) {
428    		var s = 0.0
429    		if(t) {
430      			var p = t.split(':');
431      			for(i=0;i<p.length;i++){
432					var a = String((p[i]==null)?"":p[i]);
433					s = s * 60 + parseFloat(a.replace(',', '.'))
434				}
435    		}
436    		return s;
437  		};
438
439  		var strip = function(s) {
440			var a = String((s==null)?"":s);
441    		return a.replace(/^\s+|\s+$/g,"");
442  		};
443
444		var SortArrayByKeys = function(inputarray) {
445  			var arraykeys=[];
446  			for(var k in inputarray) {arraykeys.push(k);}
447		  	arraykeys.sort();
448
449		  	var outputarray=[];
450		  	for(var i=0; i<arraykeys.length; i++) {
451				outputarray[arraykeys[i]]=inputarray[arraykeys[i]];
452		  	}
453		  	return outputarray;
454		};
455
456		var playSubtitles = function(subtitleElement) {
457    		//var srt = UTF8.encode(subtitleElement.text());
458			var srt = subtitleElement.text();
459    		subtitleElement.text('');
460    		srt = srt.replace(/\r\n|\r|\n/g, '\n')
461
462    		var subtitles = {};
463			srt = String(strip(srt));
464
465			var index = 1;
466			var srt_ = srt.split('\n\n');
467    		for(s in srt_) {
468				st = String(srt_[s]).split('\n');
469
470				if(st.length >=2) {
471					n = st[0];
472				  	i = strip(st[1].split(' --> ')[0]);
473				  	o = strip(st[1].split(' --> ')[1]);
474				  	t = st[2];
475				  	if(st.length > 2) {
476						for(j=3; j<st.length;j++)
477					  		t += '\n'+st[j];
478				  	}
479
480					is = toSeconds(i);
481				  	os = toSeconds(o);
482
483					subtitles[index] = {is:is, i:i, o: o, t: t};
484
485					index++;
486				}
487    		}
488
489			subtitles = SortArrayByKeys(subtitles);
490
491			var vlc = getVLC("vlc");
492  			if( vlc ){
493				var currentSubtitle = -1;
494				g_subtitle_timer = setInterval(function() {
495					var currentTime = parseFloat(vlc.input.time/1000);
496
497					var subtitle = -1;
498					for(var key in subtitles){
499						if(subtitles[key].is > currentTime){
500							break
501						}
502
503						subtitle = key;
504					}
505
506					if(subtitle > 0) {
507						if(subtitle != currentSubtitle) {
508							//alert(subtitles[subtitle].t);
509							subtitleElement.text(subtitles[subtitle].t);
510							currentSubtitle=subtitle;
511						}
512						else if(subtitles[subtitle].o < currentTime) {
513							subtitleElement.text('');
514						}
515					}
516					else
517						subtitleElement.text('');
518				}, 100);
519			}
520  		}
521
522    	var subtitleElement = $(this);
523		clearInterval(g_subtitle_timer);
524
525    	if( vlc ){
526			var srtUrl = subtitleElement.attr('data-srt');
527
528			if(srtUrl) {
529
530				/*
531				var that = $(this);
532				$.get( srtUrl,
533					   null,
534					   function(data){
535					alert(encodeURI(data));
536					that.text(UTF8.encode(data) );
537					playSubtitles(subtitleElement);
538				});
539				*/
540
541				$(this).load( srtUrl, function(responseText, textStatus, req) {
542					playSubtitles(subtitleElement)
543				});
544
545			}
546			else {
547				subtitleElement.text('');
548			}
549		}
550  	});
551}
552
553function createVLC() {
554	var vars = getUrlVars();
555	var loc_lan = String(window.navigator.userLanguage || window.navigator.language).toLowerCase();
556	var lan = ( g_storage.get('lan') == undefined ) ? loc_lan : g_storage.get('lan');
557	m.setLanguage(lan);
558
559	var this_showbutton = vars["showbutton"];
560	var this_video = vars["v"];
561	var this_url = vars["u"];
562
563	g_this_video = this_video;
564	g_this_video_name = this_video.substring(this_video.lastIndexOf("/")+1, this_video.lastIndexOf("."));
565	g_this_video_hash = md5(g_this_video.substr(g_this_video.lastIndexOf("/")+1, g_this_video.length));
566
567	var val = navigator.userAgent.toLowerCase();
568	var osVer = navigator.appVersion.toLowerCase();
569
570	g_isIE = isIE();
571
572	if( osVer.indexOf("mac") != -1 ){
573		document.write("<video width='320' height='240' controls='controls'>");
574  		document.write("<source src='");
575  		document.write(this_video);
576  		document.write("' type='video/x-pn-realvideo'/>");
577  		document.write("<source src='");
578  		document.write(this_video);
579  		document.write("' type='video/ogg'/>");
580		document.write("Your browser does not support the video tag.");
581		document.write("</video>");
582		return;
583	}
584
585	if(!detectVLCInstalled()){
586
587		document.write("<body width='100%' height='100%' style='margin:0px;padding:0px'>");
588
589		if(this_showbutton==1)
590			document.write("<div id='errorpage' style='overflow:none;background-image:url(vlc_bg_img.jpg);background-repeat:no-repeat;width:100%; height:94%'>");
591		else
592			document.write("<div id='errorpage' style='background-image:url(vlc_bg_img.jpg);background-repeat:no-repeat;width:100%; height:100%'>");
593		document.write("<p style='position:relative;left:54px;top:60px;width:500px;font-size:20px;color:#ffffff'>" + m.getString('msg_installvlc') + "</p>");
594		document.write("<p style='position:relative;left:54px;top:80px;width:550px;font-size:16px;color:#ffffff;text-align:left'>" + m.getString('msg_installvlc2') + "</p>");
595		document.write("<p style='position:relative;left:216px;top:100px;width:350px;font-size:14px;color:#ffffff;text-align:left'>" + m.getString('msg_installvlc3') + "</p>");
596		document.write("<a href='http://www.videolan.org/vlc/' target='_blank'><div style='width:123px;height:30px;background-image:url(downloadvlc.png);position:relative;left:456px;top:100px;cursor:pointer'></div></a>");
597		document.write("</div></body>");
598
599		if(this_showbutton==1){
600			document.write("<div width='100%'><button id='btnClose' style='position: relative;float:right;right:5px;' onclick='parent.closeJqmWindow(0);'>close</button><div>");
601		}
602
603		document.write("</body>");
604
605		window.resizeTo( 640, 460 );
606		return;
607	}
608
609	var vlc_width = "655px";
610	var vlc_height = "470px";
611
612	if(this_showbutton==1){
613		vlc_width = "655px";
614		vlc_height = "450px";
615	}
616
617	var vlc_html = "";
618	vlc_html += "<div>";
619
620	if(g_isIE){
621		vlc_html += "<OBJECT classid='clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921'";
622		vlc_html += " codebase='http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab'";
623		vlc_html += " id='vlc' name='vlc' width='" + vlc_width + "' height='" + vlc_height + "' events='True'>";
624		vlc_html += "<param name='MRL' value='' />";
625		vlc_html += "<param name='ShowDisplay' value='False'/>";
626		vlc_html += "<param name='AutoLoop' value='False'/>";
627		vlc_html += "<param name='AutoPlay' value='False'/>";
628		vlc_html += "<param name='ToolBar' value='False'/>";
629		vlc_html += "<param name='Volume' value='50' />";
630		vlc_html += "<param name='StartTime' value='0' />";
631		vlc_html += "</OBJECT>";
632	}
633	else{
634		vlc_html += "<embed type='application/x-vlc-plugin'";
635		vlc_html += " pluginspage='http://www.videolan.org'";
636		vlc_html += " width='" + vlc_width + "' height='" + vlc_height + "' id='vlc' name='vlc' version='VideoLAN.VLCPlugin.2' text='Waiting for video' Volume='50' toolbar='False' AutoPlay='False'/>";
637	}
638
639	vlc_html += "</div>";
640
641	$(vlc_html).appendTo($(".videoplayer"));
642
643	/*
644	//document.write("<div class='toolbar' style='padding: 6px 20px 0 20px;height: 50px;background: url(images/button_panel_bg.png) repeat-x;border: 0;color: #C8CDD2;'>");
645	document.write("<div class='toolbar'>");
646	document.write("<table cellspacing='0' class='toolbar-ct'>");
647	document.write("<tbody>");
648	document.write("<tr>");
649	document.write("<td class='toolbar-left' align='left'>");
650	document.write("<table>");
651	document.write("<tbody>");
652	document.write("<tr class='toolbar-left-row'>");
653	document.write("<td class='toolbar-cell'><button type='button' id='ext-gen23' class='x-btn-text play' style='width:44px !important;height: 44px !important;background: url(images/bt_play.png) no-repeat;'>&nbsp;</button></td>");
654	document.write("<td class='toolbar-cell'><button type='button' id='ext-gen25' class='x-btn-text stop' style=''>&nbsp;</button></td>");
655	//document.write("<td class="x-toolbar-cell" id="ext-gen34"><div class="xtb-text currTime" id="ext-comp-1014" style="width: 46px;">00:13</div></td>");
656	//document.write("<td class="x-toolbar-cell" id="ext-gen35"><div class="x-slider x-slider-horz seekbar" id="ext-comp-1015" style="width: 703px;"><div class="x-slider-end" id="ext-gen36"><div class="x-slider-inner" id="ext-gen37" style="width: 699px;"><div class="progress" id="ext-gen60" style="width: 6px;"></div><div class="x-slider-thumb" id="ext-gen39" style="left: -7px;"></div><a class="x-slider-focus" href="#" tabindex="-1" hidefocus="on" id="ext-gen38"></a></div></div></div></td>");
657	document.write("</tr>");
658	document.write("</tbody>");
659	document.write("</table>");
660	document.write("</td>");
661	document.write("<td class='toolbar-right' align='right'></td>");
662	document.write("</tr>");
663	document.write("</tbody>");
664	document.write("</table>");
665	document.write("<span id='info'></span>");
666	document.write("</div>");
667
668	if(this_showbutton==1){
669		document.write("<div id='footer'>");
670		document.write("<div width='100%'><button id='btnClose' style='position: relative;float:right;right:5px;' onclick='parent.closeJqmWindow(0);'>close</button></div>");
671		document.write("</div>");
672	}
673
674	document.write("</div>");
675	*/
676	/*
677	document.write("<div class='infobar'>");
678	document.write("<ol class='gbtc' style='display: block;list-style: none;margin: 0;padding: 0;'>");
679	document.write("<li class='gbt'><span id='title_aspect'>Aspect Ratio:</span>");
680  	document.write("<SELECT id='select_aspect' name='select_aspect' readonly onchange='doAspectRatio();'>");
681  	document.write("<OPTION value='default'>Default</OPTION>");
682  	document.write("<OPTION value='1:1'>1:1</OPTION>");
683  	document.write("<OPTION value='4:3'>4:3</OPTION>");
684  	document.write("<OPTION value='16:9'>16:9</OPTION>");
685  	document.write("</SELECT>");
686  	document.write("</li>");
687  	document.write("<li class='gbt'><span id='info' style='text-align:center'>-:--:--/-:--:--</span></li>");
688	document.write("</ol>");
689	document.write("</div>");
690
691	$(".gbt").css("position","relative");
692	$(".gbt").css("display","-moz-inline-box");
693	$(".gbt").css("display","inline-block");
694	$(".gbt").css("line-height","27px");
695	$(".gbt").css("padding","0");
696	$(".gbt").css("margin-left","10");
697	$(".gbt").css("vertical-align","top");
698	$(".gbt").css("line-height","19px");
699	$(".gbt").css("font-size","90%");
700
701
702  	document.write("<div width='100%'><p id='info'></p></div>");
703
704	if(this_showbutton==1){
705		document.write("<div width='100%'><button id='btnClose' style='position: relative;float:right;right:5px;' onclick='parent.closeJqmWindow(0);'>close</button></div>");
706	}
707	*/
708	//document.write("</body>");
709
710	var vlc = getVLC("vlc");
711
712	if(vlc){
713		//- Build subtitle select ui
714		var this_subtitle = (vars["s"]==undefined) ? "" : vars["s"];
715		if(this_subtitle!=""){
716			var array_subtitle = this_subtitle.split(";");
717			var b_show_subtitle_ctrl = false;
718			var select_option_html = "<option value=''>" + m.getString('title_no_subtitle') + "</option>";
719			for(var i=0; i < array_subtitle.length; i++){
720				var url = array_subtitle[i];
721				if(url!=""){
722					var filename = url.substr( url.lastIndexOf("/")+1, url.length );
723					var srt_url = window.location.protocol + "//" + window.location.host + array_subtitle[i];
724					select_option_html += "<option value='" + srt_url + "'";
725
726					//- default
727					if(filename.indexOf(g_this_video_name)==0){
728						select_option_html += "selected ";
729						$(".subtitle").attr("data-srt", srt_url);
730					}
731
732					select_option_html += ">" + filename + "</option>";
733					b_show_subtitle_ctrl = true;
734				}
735			}
736
737			$(select_option_html).appendTo($("#select_subtitle"));
738			$(".subtitle-ctrl").css("display", ((b_show_subtitle_ctrl) ? "block" : "none" ));
739
740			play_subtitle();
741		}
742		else{
743			var b_show_subtitle_ctrl = false;
744			var select_option_html = "<option value=''>" + m.getString('title_no_subtitle') + "</option>";
745			var client = new davlib.DavClient();
746			client.initialize();
747			//var open_url = g_storage.get('openurl');
748			var open_url = this_url;
749
750			client.GETVIDEOSUBTITLE(open_url, g_this_video_name, function(error, statusstring, content){
751				if(error==200){
752					var data = parseXml(content);
753
754					$(data).find("file").each(function(i) {
755						var filename = $(this).find("name").text();
756						var srt_url = window.location.protocol + "//" + window.location.host + "/" + $(this).find("sharelink").text();
757
758						select_option_html += "<option value='" + srt_url + "'";
759
760						//- default
761						if(filename.indexOf(g_this_video_name)==0){
762							select_option_html += "selected ";
763							$(".subtitle").attr("data-srt", srt_url);
764						}
765
766						select_option_html += ">" + filename + "</option>";
767						b_show_subtitle_ctrl = true;
768					});
769
770					$(select_option_html).appendTo($("#select_subtitle"));
771					$(".subtitle-ctrl").css("display", ((b_show_subtitle_ctrl) ? "block" : "none" ));
772
773					play_subtitle();
774				}
775			});
776			client = null;
777		}
778
779		g_play_id = vlc.playlist.add(this_video);
780
781		if(g_play_id==-1){
782    		alert("cannot play at the moment !");
783		}
784		else{
785			if(g_isIE){
786				vlc.style.width = vlc_width;
787				vlc.style.height = vlc_height;
788			}
789
790			setInterval( "monitor()", 1000 );
791			doPlay();
792
793			$(".toolbar").css("display", "block");
794			var min_pos = parseInt($(".volumebar .slider-progress").css("left"));
795			//var pos = (vlc.audio.volume/200)*74;
796			var pos = 37;
797			$(".volumebar .slider-thumb").css("left", pos);
798			$(".volumebar .slider-progress").css("width", pos-min_pos);
799
800			var last_time = g_storage.getl(g_this_video_hash);
801			if(last_time!=undefined){
802				if(confirm(m.getString("msg_last_playtime"))) {
803					vlc.input.time = parseInt(last_time);
804				}
805			}
806		}
807	}
808
809	$('#label_subtitle').text(m.getString("title_subtitle_file") + ": ");
810	$('button#btnClose').text(m.getString("btn_close"));
811	$(".footer").css("display", "block");
812
813	/*
814	$('span#title_aspect').text(m.getString("title_aspect")+": ");
815	$('#select_aspect').change(function(){
816	    var vlc = getVLC("vlc");
817
818	    if( vlc )
819	        vlc.video.aspectRatio = $("#select_aspect").val();
820	});
821	*/
822
823	$(".play").click(function(){
824		doPlay();
825	});
826
827	$(".pause").click(function(){
828		doPause();
829	});
830
831	$(".stop").click(function(){
832		doStop();
833	});
834
835	$(".playbar .slider-thumb").draggable({
836		axis: "x",
837		snap: 'true',
838		cursor: 'move',
839		start: function( event, ui ) {
840			//doPause();
841			/*
842			var vlc = getVLC("vlc");
843  			if( vlc ){
844				if(g_isIE)
845					vlc.playlist.stop();
846				else
847					vlc.playlist.pause();
848			}
849			*/
850		},
851		drag: function( event, ui ) {
852			var min_pos = 0;
853			//var max_pos = $(".playbar .slider-tracker").width() + $(".playbar .slider-thumb").width();
854			var max_pos = $(".playbar .slider-tracker").width();
855			if(ui.position.left <= min_pos)
856				ui.position.left = min_pos;
857			if(ui.position.left >= max_pos)
858				ui.position.left = max_pos;
859
860			//$(".playbar .slider-progress").css("width", ui.position.left+($(".playbar .slider-thumb").width()/2));
861			$(".playbar .slider-progress").css("width", ui.position.left);
862		},
863		stop: function( event, ui ) {
864			var mediaLen = 0;
865			var vlc = getVLC("vlc");
866  			if( vlc ){
867  				mediaLen = vlc.input.length;
868
869				if(mediaLen>0){
870					var time = (ui.position.left / $(".playbar .slider-tracker").width())*mediaLen;
871					vlc.input.time = time;
872					vlc.playlist.play();
873				}
874			}
875		}
876	});
877
878	$(".volumebar .slider-thumb").draggable({
879		axis: "x",
880		snap: 'true',
881		cursor: 'move',
882		drag: function( event, ui ) {
883			var min_pos = parseInt($(".volumebar .slider-progress").css("left"));
884			var max_pos = 74 - $(".volumebar .slider-thumb").width() + min_pos;
885			if(ui.position.left <= min_pos)
886				ui.position.left = min_pos;
887			if(ui.position.left >= max_pos)
888				ui.position.left = max_pos;
889
890			$(".volumebar .slider-progress").css("width", ui.position.left-min_pos);
891
892			var vlc = getVLC("vlc");
893  			if( vlc ){
894  				var vol = (ui.position.left / 74)*200;
895				vlc.audio.volume = vol;
896			}
897		},
898		stop: function( event, ui ) {
899			var vlc = getVLC("vlc");
900  			if( vlc ){
901  				var vol = (ui.position.left / 74)*200;
902				vlc.audio.volume = vol;
903			}
904		}
905	});
906
907	$('#select_subtitle').change(function(){
908		$(".subtitle").attr("data-srt", $(this).attr("value"));
909		play_subtitle();
910	});
911
912	//play_subtitle();
913}