@stremio/stremio-video 0.0.25-rc.1 → 0.0.25-rc.2

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@stremio/stremio-video",
3
- "version": "0.0.25-rc.1",
3
+ "version": "0.0.25-rc.2",
4
4
  "description": "Abstraction layer on top of different media players",
5
5
  "author": "Smart Code OOD",
6
6
  "main": "src/index.js",
@@ -204,7 +204,7 @@ function TizenVideo(options) {
204
204
  try {
205
205
  extra = JSON.parse(textTrack.extra_info);
206
206
  } catch(e) {}
207
- var textTrackLang = (extra.track_lang || '').trim();
207
+ var textTrackLang = typeof extra.track_lang === 'string' && extra.track_lang.length > 0 ? extra.track_lang.trim() : null;
208
208
  textTracks.push({
209
209
  id: textTrackId,
210
210
  lang: textTrackLang,
@@ -291,7 +291,7 @@ function TizenVideo(options) {
291
291
  try {
292
292
  extra = JSON.parse(audioTrack.extra_info);
293
293
  } catch(e) {}
294
- var audioTrackLang = extra.language || '';
294
+ var audioTrackLang = typeof extra.language === 'string' && extra.language.length > 0 ? extra.language : null;
295
295
  audioTracks.push({
296
296
  id: audioTrackId,
297
297
  lang: audioTrackLang,
@@ -15,12 +15,11 @@ function luna(params, call, fail, method) {
15
15
  window.webOS.service.request(method || 'luna://com.webos.media', params);
16
16
  }
17
17
 
18
- function runWebOS(params, failed) {
19
- // console.log('run web os', params);
18
+ function launchVideoApp(params, success, failure) {
20
19
  window.webOS.service.request('luna://com.webos.applicationManager', {
21
20
  method: 'launch',
22
21
  parameters: {
23
- 'id': params.need,
22
+ 'id': params.id,
24
23
  'params': {
25
24
  'payload':[
26
25
  {
@@ -46,19 +45,17 @@ function runWebOS(params, failed) {
46
45
  }
47
46
  },
48
47
  onSuccess: function () {
49
- // console.log('The app is launched');
48
+ success && success();
50
49
  },
51
- onFailure: function () { // function(inError)
52
- // console.log('Player', 'Failed to launch the app ('+params.need+'): ', '[' + inError.errorCode + ']: ' + inError.errorText);
53
-
54
- if (params.need === 'com.webos.app.photovideo') {
55
- params.need = 'com.webos.app.smartshare';
56
- runWebOS(params);
57
- } else if(params.need === 'com.webos.app.smartshare') {
58
- params.need = 'com.webos.app.mediadiscovery';
59
- runWebOS(params);
60
- } else if (params.need === 'com.webos.app.mediadiscovery') {
61
- failed();
50
+ onFailure: function () {
51
+ failure && failure(new Error('Failed to launch' + params.id));
52
+
53
+ if (params.id === 'com.webos.app.photovideo') {
54
+ params.id = 'com.webos.app.smartshare';
55
+ launchVideoApp(params, success, failure);
56
+ } else if(params.id === 'com.webos.app.smartshare') {
57
+ params.id = 'com.webos.app.mediadiscovery';
58
+ launchVideoApp(params, success, failure);
62
59
  }
63
60
  }
64
61
  });
@@ -599,21 +596,27 @@ function WebOsVideo(options) {
599
596
  }
600
597
  case 3: {
601
598
  error = ERROR.HTML_VIDEO.MEDIA_ERR_DECODE;
602
- runWebOS({
603
- need: 'com.webos.app.photovideo',
599
+ launchVideoApp({
600
+ id: 'com.webos.app.photovideo',
604
601
  url: stream.url,
605
602
  name: 'Stremio',
606
603
  position: -1,
604
+ }, null, function(e) {
605
+ // eslint-disable-next-line no-console
606
+ console.error(e);
607
607
  });
608
608
  break;
609
609
  }
610
610
  case 4: {
611
611
  error = ERROR.HTML_VIDEO.MEDIA_ERR_SRC_NOT_SUPPORTED;
612
- runWebOS({
613
- need: 'com.webos.app.photovideo',
612
+ launchVideoApp({
613
+ id: 'com.webos.app.photovideo',
614
614
  url: stream.url,
615
615
  name: 'Stremio',
616
616
  position: -1,
617
+ }, null, function(e) {
618
+ // eslint-disable-next-line no-console
619
+ console.error(e);
617
620
  });
618
621
  break;
619
622
  }