annotate nodejs/examples/mce/epg.js @ 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.
author wycc
date Tue, 09 Nov 2010 07:41:52 +0800
parents
children 18329b6f77a4
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 () {
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
31 res = JSON.parse(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
32 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
33 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
34
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
35 });
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
36 });
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 }
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
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 * 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
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 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
45 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
46 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
47 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
48 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
49 sys.puts("ext="+ext);
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 if (ext != '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
51 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
52 pngfile = fields.join('.');
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 }
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 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
55 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
56 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
57 } 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
58 }
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 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
60 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
61 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
62 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
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 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
65 } 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
66 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
67 }
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
68 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
69 }
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
70
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
71 /**
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
72 * 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
73 */
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 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
75 {
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 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
77 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
78 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
79 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
80 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
81 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
82 } 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
83 }
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 }
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 /*
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 * 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
88 * 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
89 */
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 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
91 {
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 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
93 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
94 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
95 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
96 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
97
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 // 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
99 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
100 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
101 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
102 '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
103 '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
104 '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
105 '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
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 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
108 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
109 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
110 }
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 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
112 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
113 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
114 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
115 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
116 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
117 });
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 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
119 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
120 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
121 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
122 if (ext != "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
123 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
124 newf = fields.join(".");
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 os.spawn("convert",[file,newf]);
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 } 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
127 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
128 }
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 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
130 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
131 } 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
132 }
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 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
134 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
135 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
136 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
137 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
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
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 });
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
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 }
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
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 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
146 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
147 this.pend = cats.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
148 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
149 c = cats[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
150 httpGetFile(c['ProgramPIC'],'cat'+i+'.png',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
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.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
156 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
157 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
158 }
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
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 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
161 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
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 exports.EPG = EPG;