@krx3d/tizentube2 1.31.560 → 1.31.580

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@krx3d/tizentube2",
3
3
  "appName": "TizenTube",
4
- "version": "1.31.560",
4
+ "version": "1.31.580",
5
5
  "description": "TizenTube is an ad-free and sponsor-free solution for your favourite streaming website on your Tizen (Samsung) TVs.",
6
6
  "packageType": "mods",
7
7
  "websiteURL": "https://youtube.com/tv?additionalDataUrl=http%3A%2F%2Flocalhost%3A8085%2Fdial%2Fapps%2FYouTube",
@@ -14,6 +14,8 @@
14
14
  <icon src="icon_16b9.png" width="1920" height="1080"/>
15
15
  <icon src="icon.png" width="1024" height="1024"/>
16
16
  <tizen:metadata key="http://samsung.com/tv/metadata/prelaunch.support" value="true"/>
17
+ <!-- Smart Hub Preview (test build): the row shown when the app is highlighted on the home bar. See preview/preview.js. -->
18
+ <tizen:metadata key="http://samsung.com/tv/metadata/use.preview" value="bg_service"/>
17
19
  <tizen:metadata key="http://samsung.com/tv/metadata/floating.navigation" value="false"/>
18
20
  <tizen:metadata key="http://samsung.com/tv/metadata/use.game.mode" value="true"/>
19
21
  <tizen:metadata key="http://samsung.com/tv/metadata/use.uwe" value="true"/>
@@ -37,5 +39,11 @@
37
39
  <tizen:name>StandaloneService</tizen:name>
38
40
  <tizen:description>StandaloneService</tizen:description>
39
41
  </tizen:service>
42
+ <tizen:service id="krx3dTtSt1.PreviewService">
43
+ <tizen:content src="preview/preview.js"/>
44
+ <tizen:name>PreviewService</tizen:name>
45
+ <tizen:description>Smart Hub Preview</tizen:description>
46
+ <tizen:category name="http://tizen.org/category/service"/>
47
+ </tizen:service>
40
48
  <tizen:setting screen-orientation="landscape" context-menu="enable" background-support="enable" encryption="disable" install-location="auto" hwkey-event="enable"/>
41
49
  </widget>
@@ -253,6 +253,7 @@
253
253
  .then(r => r.json())
254
254
  .then(res => {
255
255
  sendLog('INFO', 'getState resolved: ' + JSON.stringify(res));
256
+ previewTest();
256
257
  if (res.canConnectToDaemon && !res.isConnecting) {
257
258
  sendLog('INFO', 'Taking CDP-injection path, launching debugger and exiting');
258
259
  breadcrumb('cdp-handoff');
@@ -510,6 +511,48 @@
510
511
  attempt();
511
512
  }
512
513
 
514
+ // Smart Hub Preview test build (see preview/preview.js). Called once
515
+ // the service answers, so the report has somewhere to go.
516
+ var previewTestDone = false;
517
+ function previewTest() {
518
+ if (previewTestDone) return;
519
+ previewTestDone = true;
520
+ function report(level, message) {
521
+ try {
522
+ fetch('http://localhost:8099/tizentube/previewEvent', {
523
+ method: 'POST',
524
+ headers: { 'Content-Type': 'application/json' },
525
+ body: JSON.stringify({ level: level, message: '[index.html] ' + message })
526
+ }).catch(function () {});
527
+ } catch (e) {}
528
+ }
529
+ // A tile on the home bar starts the app with its action_data under
530
+ // the key PAYLOAD. Only reported for now; opening the video comes
531
+ // once the row is known to work.
532
+ try {
533
+ var data = tizen.application.getCurrentApplication().getRequestedAppControl().appControl.data || [];
534
+ var keys = [];
535
+ for (var i = 0; i < data.length; i++) {
536
+ keys.push(data[i].key);
537
+ if (data[i].key === 'PAYLOAD') report('INFO', 'started from a preview tile, PAYLOAD=' + String(data[i].value && data[i].value[0]).slice(0, 300));
538
+ }
539
+ report('INFO', 'launch app-control keys: ' + JSON.stringify(keys));
540
+ } catch (e) {
541
+ report('ERROR', 'reading app-control failed: ' + (e && e.message || e));
542
+ }
543
+ try {
544
+ tizen.application.launchAppControl(
545
+ new tizen.ApplicationControl('http://tizen.org/appcontrol/operation/pick', null, 'image/jpeg', null,
546
+ [new tizen.ApplicationControlData('caller', ['ForegroundApp'])]),
547
+ pkgId + '.PreviewService',
548
+ function () { report('INFO', 'PreviewService launched'); },
549
+ function (e) { report('ERROR', 'PreviewService launch failed: ' + (e && e.message || e)); }
550
+ );
551
+ } catch (e) {
552
+ report('ERROR', 'PreviewService launch threw: ' + (e && e.message || e));
553
+ }
554
+ }
555
+
513
556
  function launchService() {
514
557
  sendLog('INFO', 'Launching StandaloneService via launchAppControl');
515
558
  breadcrumb('launch-service');
@@ -0,0 +1,117 @@
1
+ // Smart Hub Preview: TEST BUILD.
2
+ //
3
+ // Asked for: a row of TizenTube content on the TV's home bar when the app
4
+ // is highlighted, the way Emby shows one. That is Samsung's Smart Hub
5
+ // Preview: a background service hands a JSON description of the row to
6
+ // webapis.preview.setPreviewData(). This first version only answers whether
7
+ // the row appears on these TVs at all, so it publishes three fixed tiles.
8
+ // Real rows (Continue Watching, new from subscriptions) come after.
9
+ //
10
+ // A service of its own rather than part of StandaloneService: Samsung's
11
+ // sample calls exit() right after setPreviewData, and a preview service that
12
+ // does not exit is terminated after five minutes. StandaloneService has to
13
+ // keep running for the proxy and the injector.
14
+ //
15
+ // Plain ES5 on purpose. The 5.0 TV runs services on Node 4.4.3, and this
16
+ // file is copied as-is (nothing bundles or transpiles it).
17
+ //
18
+ // The system launches this service by itself roughly every ten minutes;
19
+ // index.html also launches it on every start (the operation and caller data
20
+ // match Samsung's BackgroundServiceLocal sample).
21
+
22
+ var http = require('http');
23
+
24
+ // Lines land in the syslog through StandaloneService, when it is running.
25
+ function report(level, message) {
26
+ try {
27
+ var body = JSON.stringify({ level: level, message: '[PreviewService] ' + message });
28
+ var req = http.request({
29
+ host: '127.0.0.1',
30
+ port: 8099,
31
+ path: '/tizentube/previewEvent',
32
+ method: 'POST',
33
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }
34
+ });
35
+ req.on('error', function () {});
36
+ req.setTimeout(3000, function () { req.abort(); });
37
+ req.end(body);
38
+ } catch (e) {}
39
+ }
40
+
41
+ function tile(videoId, title, subtitle) {
42
+ return {
43
+ title: title,
44
+ subtitle: subtitle,
45
+ // hqdefault is 480x360, inside Samsung's 4:3 limits (333x250 to
46
+ // 480x360) and well under the 360 KB cap.
47
+ image_url: 'https://i.ytimg.com/vi/' + videoId + '/hqdefault.jpg',
48
+ image_ratio: '4by3',
49
+ action_data: JSON.stringify({ videoId: videoId }),
50
+ is_playable: true
51
+ };
52
+ }
53
+
54
+ var PREVIEW = {
55
+ sections: [{
56
+ title: 'TizenTube (Test)',
57
+ tiles: [
58
+ tile('aqz-KE-bpKQ', 'Big Buck Bunny', 'Test tile 1'),
59
+ tile('eRsGyueVLvQ', 'Sintel', 'Test tile 2'),
60
+ tile('R6MlUcmOul8', 'Tears of Steel', 'Test tile 3')
61
+ ]
62
+ }]
63
+ };
64
+
65
+ var started = Date.now();
66
+
67
+ function exitSoon() {
68
+ // Give the report a moment to leave before the process goes.
69
+ setTimeout(function () {
70
+ try { tizen.application.getCurrentApplication().exit(); } catch (e) {}
71
+ }, 1500);
72
+ }
73
+
74
+ function publish(trigger) {
75
+ var hasPreview = typeof webapis !== 'undefined' && webapis && webapis.preview
76
+ && typeof webapis.preview.setPreviewData === 'function';
77
+ if (!hasPreview) {
78
+ report('ERROR', 'webapis.preview is not available in this service (trigger ' + trigger
79
+ + ', webapis ' + (typeof webapis) + ')');
80
+ exitSoon();
81
+ return;
82
+ }
83
+ var version = '';
84
+ try { version = webapis.preview.getVersion(); } catch (e) { version = 'n/a'; }
85
+ try {
86
+ webapis.preview.setPreviewData(JSON.stringify(PREVIEW), function () {
87
+ report('INFO', 'setPreviewData succeeded (trigger ' + trigger + ', preview API ' + version
88
+ + ', ' + (Date.now() - started) + ' ms after start)');
89
+ exitSoon();
90
+ }, function (err) {
91
+ report('ERROR', 'setPreviewData failed (trigger ' + trigger + '): '
92
+ + (err && (err.name + ': ' + err.message) || err));
93
+ exitSoon();
94
+ });
95
+ } catch (e) {
96
+ report('ERROR', 'setPreviewData threw (trigger ' + trigger + '): ' + (e && e.message || e));
97
+ exitSoon();
98
+ }
99
+ }
100
+
101
+ module.exports.onStart = function () {
102
+ report('INFO', 'onStart');
103
+ };
104
+
105
+ module.exports.onRequest = function () {
106
+ var trigger = 'system';
107
+ try {
108
+ var req = tizen.application.getCurrentApplication().getRequestedAppControl();
109
+ var data = req && req.appControl && req.appControl.data || [];
110
+ for (var i = 0; i < data.length; i++) {
111
+ if (data[i].key === 'caller' && data[i].value && data[i].value[0] === 'ForegroundApp') trigger = 'app';
112
+ }
113
+ } catch (e) {}
114
+ publish(trigger);
115
+ };
116
+
117
+ module.exports.onExit = function () {};