annotate nodejs/examples/mce/epg.js @ 1388:669f79a4ecaf

Fix the parseUse which setup parameter to the wrong object.
author wycc
date Fri, 25 Mar 2011 03:54:45 +0800
parents 9f3f20c4a4fb
children b8ba20b8f91a
rev   line source
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
2 // vim: sw=4:ts=8:sts=4
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
3 var http = require('http');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
4 var URL = require('url');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
5 var sys = require("sys");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
6 var fs = require("fs");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
7 var os = require("child_process");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
8 function EPG()
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
9 {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
10 var epgsrv = http.createClient(8080, '211.23.50.144');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
11 var cmd = '{"Protocol":"EPG-CSP","Command":"SearchRequest","ProgramCat":"MainCat"}';
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
12 var headers={
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
13 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
14 'Host':'211.23.50.144:8080',
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
15 'User-Agent':'MadButterfly',
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
16 'Content-Type':'application/x-www-form-urlencoded'
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
17 };
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
18 headers['Content-Length'] = cmd.length;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
19 var request = epgsrv.request('POST', '/IPTV_EPG/EPGService.do?timestamp='+new Date().getTime(),headers);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
20 var self = this;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
21 sys.puts("aaaa");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
22 var js = '';
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
23 request.write(cmd);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
24 request.end();
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
25 request.on('response', function(res) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
26 sys.puts("connected");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
27 res.on('data',function (data) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
28 js = js + data;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
29 });
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
30 res.on('end', function () {
1122
3d438daea48c Add the handler for the next page
wycc
parents: 1065
diff changeset
31 try {
3d438daea48c Add the handler for the next page
wycc
parents: 1065
diff changeset
32 res = JSON.parse(js);
3d438daea48c Add the handler for the next page
wycc
parents: 1065
diff changeset
33 } catch(e) {
3d438daea48c Add the handler for the next page
wycc
parents: 1065
diff changeset
34 sys.puts(e);
3d438daea48c Add the handler for the next page
wycc
parents: 1065
diff changeset
35 sys.puts(js);
3d438daea48c Add the handler for the next page
wycc
parents: 1065
diff changeset
36 }
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
37 sys.puts("parsed");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
38 self.onLoad(res);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
39
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
40 });
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
41 });
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
42 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
43
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
44
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
45 /**
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
46 * Check if the file has been cached. Create a symbolic to link if it is cached already.
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
47 *
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
48 */
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
49 function isCached(cachepath,file,obj) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
50 var fields = cachepath.split('.');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
51 try {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
52 var ext = fields.pop();
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
53 var pngfile = cachepath;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
54 sys.puts("ext="+ext);
1386
9f3f20c4a4fb Use jpg instead of PNG.
wycc
parents: 1122
diff changeset
55 //if (ext != 'png') {
9f3f20c4a4fb Use jpg instead of PNG.
wycc
parents: 1122
diff changeset
56 // fields.push('png');
9f3f20c4a4fb Use jpg instead of PNG.
wycc
parents: 1122
diff changeset
57 // pngfile = fields.join('.');
9f3f20c4a4fb Use jpg instead of PNG.
wycc
parents: 1122
diff changeset
58 //}
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
59 var st = fs.statSync(pngfile);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
60 try {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
61 fs.unlinkSync(file);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
62 } catch(e) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
63 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
64 fs.linkSync(pngfile, file);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
65 obj.pend = obj.pend - 1;
1386
9f3f20c4a4fb Use jpg instead of PNG.
wycc
parents: 1122
diff changeset
66 try {
9f3f20c4a4fb Use jpg instead of PNG.
wycc
parents: 1122
diff changeset
67 if (obj.pend == 0) {
9f3f20c4a4fb Use jpg instead of PNG.
wycc
parents: 1122
diff changeset
68 obj.onInitDone();
9f3f20c4a4fb Use jpg instead of PNG.
wycc
parents: 1122
diff changeset
69 }
9f3f20c4a4fb Use jpg instead of PNG.
wycc
parents: 1122
diff changeset
70 } catch(e) {
9f3f20c4a4fb Use jpg instead of PNG.
wycc
parents: 1122
diff changeset
71 sys.puts(e);
9f3f20c4a4fb Use jpg instead of PNG.
wycc
parents: 1122
diff changeset
72 }
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
73 return 1;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
74 } catch(e) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
75 sys.puts(e);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
76 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
77 return 0;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
78 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
79
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
80 /**
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
81 * Implement the mkdir -p to create the directory
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
82 */
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
83 function CreateDirectory(cachepath)
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
84 {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
85 var fields = cachepath.split('/');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
86 var p='';
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
87 for(i=0;i<fields.length-1;i++) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
88 p = p + fields[i]+'/';
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
89 try {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
90 fs.mkdirSync(p,0777);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
91 } catch(e) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
92 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
93 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
94 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
95 /*
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
96 * We will check the cache directory. If the file is available, we will create a symbolic link only. Otherwise,
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
97 * we will fetch it before create the symbolic link.
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
98 */
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
99 function httpGetFile(url,file,obj)
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
100 {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
101 sys.puts("fetch "+ file);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
102 var u = URL.parse(url);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
103 var cachepath = 'cache/'+u.pathname;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
104 if (isCached(cachepath,file,obj)) return;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
105 CreateDirectory(cachepath);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
106
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
107 // Fetch file from the server and convert it tyo PNG if it is not PNG format.
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
108 var f = fs.openSync(cachepath,'w');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
109 sys.puts("f="+f);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
110 var headers={
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
111 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
112 'Host':'211.23.50.144:8080',
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
113 'User-Agent':'MadButterfly',
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
114 'Content-Type':'application/x-www-form-urlencoded'
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
115 };
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
116 sys.puts("host="+u.host+' '+u.port+' '+u.pathname);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
117 for(k in u) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
118 sys.puts(k+"--->"+u[k]);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
119 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
120 var c = http.createClient(8080,'211.23.50.144');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
121 var req = c.request('GET',u.pathname,headers);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
122 req.end();
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
123 req.on('response', function(res) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
124 res.on('data',function(data) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
125 fs.writeSync(f,data,0,data.length);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
126 });
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
127 res.on('end',function() {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
128 fs.close(f);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
129 var fields = cachepath.split('.');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
130 var ext = fields.pop();
1122
3d438daea48c Add the handler for the next page
wycc
parents: 1065
diff changeset
131 if (ext != "png" && ext != 'jpg') {
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
132 fields.push("png");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
133 newf = fields.join(".");
1035
18329b6f77a4 Generate the PNG fropm the JPG file. We need to add the JPG/GIF graphics format
wycc
parents: 932
diff changeset
134 sys.puts("cachepath="+cachepath+" newf="+newf);
18329b6f77a4 Generate the PNG fropm the JPG file. We need to add the JPG/GIF graphics format
wycc
parents: 932
diff changeset
135 os.spawn("convert",[cachepath,newf]);
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
136 } else {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
137 newf = cachepath;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
138 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
139 try {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
140 fs.unlinkSync(file);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
141 } catch(e) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
142 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
143 sys.puts("end of "+cachepath+" to "+file);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
144 fs.symlinkSync(newf, file);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
145 obj.pend = obj.pend - 1;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
146 if (obj.pend == 0) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
147 obj.onInitDone();
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
148 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
149
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
150 });
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
151
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
152 });
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
153 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
154
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
155 EPG.prototype.onLoad = function(res) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
156 cats = res['ProgramCat'];
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
157 this.pend = cats.length;
1065
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
158 this.maincat = cats;
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
159 for (i in cats) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
160 c = cats[i];
1386
9f3f20c4a4fb Use jpg instead of PNG.
wycc
parents: 1122
diff changeset
161 httpGetFile(c['ProgramPIC'],'cat'+i+'.jpg',this);
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
162 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
163 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
164
1065
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
165 EPG.prototype.getList=function(item,func) {
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
166 var epgsrv = http.createClient(8080, '211.23.50.144');
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
167 var cmd = '{"Protocol":"EPG-CSP","Command":"SearchRequest","ProgramSub":"'+item.Category+'"}';
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
168 var headers={
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
169 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
170 'Host':'211.23.50.144:8080',
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
171 'User-Agent':'MadButterfly',
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
172 'Content-Type':'application/x-www-form-urlencoded'
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
173 };
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
174 headers['Content-Length'] = cmd.length;
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
175 var request = epgsrv.request('POST', '/IPTV_EPG/EPGService.do?timestamp='+new Date().getTime(),headers);
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
176 var self = this;
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
177 sys.puts("aaaa");
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
178 var js = '';
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
179 request.write(cmd);
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
180 request.end();
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
181 request.on('response', function(res) {
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
182 sys.puts("connected");
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
183 res.on('data',function (data) {
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
184 js = js + data;
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
185 });
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
186 res.on('end', function () {
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
187 res = JSON.parse(js);
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
188 sys.puts("parsed");
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
189 func();
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
190
1065
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
191 });
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
192 });
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
193 }
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
194 EPG.prototype.onInitDone=function() {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
195 if (this.loadCallback)
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
196 this.loadCallback();
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
197 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
198
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
199 EPG.prototype.registerInitDone=function(cb) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
200 this.loadCallback = cb;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
201 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
202
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
203 exports.EPG = EPG;