@stremio/stremio-video 0.0.79-tizen02 → 0.0.80
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
|
@@ -257,8 +257,9 @@ function ShellVideo(options) {
|
|
|
257
257
|
}
|
|
258
258
|
});
|
|
259
259
|
ipc.on('mpv-event-ended', function(args) {
|
|
260
|
+
// older shells report 'other' for every non-error reason, including eof
|
|
260
261
|
if (args.error) onError(args.error);
|
|
261
|
-
else onEnded();
|
|
262
|
+
else if (!args.reason || args.reason === 'eof' || args.reason === 'other') onEnded();
|
|
262
263
|
});
|
|
263
264
|
|
|
264
265
|
function getProp(propName) {
|
|
@@ -4,7 +4,6 @@ var deepFreeze = require('deep-freeze');
|
|
|
4
4
|
var Color = require('color');
|
|
5
5
|
var ERROR = require('../error');
|
|
6
6
|
var getTracksData = require('../tracksData');
|
|
7
|
-
var createAVPlay = require('./AVPlay');
|
|
8
7
|
|
|
9
8
|
var SSA_DESCRIPTORS_REGEX = /^\{(\\an[1-8])+\}/i;
|
|
10
9
|
|
|
@@ -21,7 +20,7 @@ function TizenVideo(options) {
|
|
|
21
20
|
throw new Error('Container element required to be instance of HTMLElement');
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
var AVPlay =
|
|
23
|
+
var AVPlay = window.webapis.avplay;
|
|
25
24
|
|
|
26
25
|
var promiseAudioTrackChange = false;
|
|
27
26
|
|
|
@@ -41,17 +40,17 @@ function TizenVideo(options) {
|
|
|
41
40
|
var lastSub;
|
|
42
41
|
var disabledSubs = true;
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
function refreshSubtitle() {
|
|
45
44
|
if (lastSub) {
|
|
46
|
-
var currentTime =
|
|
45
|
+
var currentTime = getProp('time');
|
|
47
46
|
var lastSubDurationDiff = lastSub.duration - (currentTime - lastSub.now);
|
|
48
47
|
if (lastSubDurationDiff > 0) renderSubtitle(lastSubDurationDiff, lastSub.text);
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
|
|
51
|
+
function renderSubtitle(duration, text) {
|
|
53
52
|
if (disabledSubs) return;
|
|
54
|
-
var now =
|
|
53
|
+
var now = getProp('time');
|
|
55
54
|
var cleanedText = text.replace(SSA_DESCRIPTORS_REGEX, '');
|
|
56
55
|
|
|
57
56
|
// we ignore custom delay here, it's not needed for embedded subs
|
|
@@ -178,7 +177,7 @@ function TizenVideo(options) {
|
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
179
|
|
|
181
|
-
|
|
180
|
+
function getProp(propName) {
|
|
182
181
|
switch (propName) {
|
|
183
182
|
case 'stream': {
|
|
184
183
|
return stream;
|
|
@@ -191,7 +190,7 @@ function TizenVideo(options) {
|
|
|
191
190
|
return null;
|
|
192
191
|
}
|
|
193
192
|
|
|
194
|
-
var state =
|
|
193
|
+
var state = AVPlay.getState();
|
|
195
194
|
var isPaused = !!(state === 'PAUSED');
|
|
196
195
|
|
|
197
196
|
if (!isPaused && promiseAudioTrackChange) {
|
|
@@ -202,7 +201,7 @@ function TizenVideo(options) {
|
|
|
202
201
|
return isPaused;
|
|
203
202
|
}
|
|
204
203
|
case 'time': {
|
|
205
|
-
var currentTime =
|
|
204
|
+
var currentTime = AVPlay.getCurrentTime();
|
|
206
205
|
if (stream === null || currentTime === null || !isFinite(currentTime)) {
|
|
207
206
|
return null;
|
|
208
207
|
}
|
|
@@ -210,7 +209,7 @@ function TizenVideo(options) {
|
|
|
210
209
|
return Math.floor(currentTime);
|
|
211
210
|
}
|
|
212
211
|
case 'duration': {
|
|
213
|
-
var duration =
|
|
212
|
+
var duration = AVPlay.getDuration();
|
|
214
213
|
if (stream === null || duration === null || !isFinite(duration)) {
|
|
215
214
|
return null;
|
|
216
215
|
}
|
|
@@ -229,7 +228,7 @@ function TizenVideo(options) {
|
|
|
229
228
|
return [];
|
|
230
229
|
}
|
|
231
230
|
|
|
232
|
-
var totalTrackInfo =
|
|
231
|
+
var totalTrackInfo = AVPlay.getTotalTrackInfo();
|
|
233
232
|
var textTracks = [];
|
|
234
233
|
|
|
235
234
|
for (var i = 0; i < totalTrackInfo.length; i++) {
|
|
@@ -269,7 +268,7 @@ function TizenVideo(options) {
|
|
|
269
268
|
return null;
|
|
270
269
|
}
|
|
271
270
|
|
|
272
|
-
var currentTracks =
|
|
271
|
+
var currentTracks = AVPlay.getCurrentStreamInfo();
|
|
273
272
|
var currentIndex;
|
|
274
273
|
|
|
275
274
|
for (var i = 0; i < currentTracks.length; i++) {
|
|
@@ -330,7 +329,7 @@ function TizenVideo(options) {
|
|
|
330
329
|
return [];
|
|
331
330
|
}
|
|
332
331
|
|
|
333
|
-
var totalTrackInfo =
|
|
332
|
+
var totalTrackInfo = AVPlay.getTotalTrackInfo();
|
|
334
333
|
var audioTracks = [];
|
|
335
334
|
|
|
336
335
|
for (var i = 0; i < totalTrackInfo.length; i++) {
|
|
@@ -377,7 +376,7 @@ function TizenVideo(options) {
|
|
|
377
376
|
return promiseAudioTrackChange;
|
|
378
377
|
}
|
|
379
378
|
|
|
380
|
-
var currentTracks =
|
|
379
|
+
var currentTracks = AVPlay.getCurrentStreamInfo();
|
|
381
380
|
var currentIndex = false;
|
|
382
381
|
|
|
383
382
|
for (var i = 0; i < currentTracks.length; i++) {
|
|
@@ -411,20 +410,20 @@ function TizenVideo(options) {
|
|
|
411
410
|
function onEnded() {
|
|
412
411
|
events.emit('ended');
|
|
413
412
|
}
|
|
414
|
-
|
|
413
|
+
function onPropChanged(propName) {
|
|
415
414
|
if (observedProps[propName]) {
|
|
416
|
-
var propValue =
|
|
415
|
+
var propValue = getProp(propName);
|
|
417
416
|
events.emit('propChanged', propName, propValue);
|
|
418
417
|
}
|
|
419
418
|
}
|
|
420
|
-
|
|
419
|
+
function observeProp(propName) {
|
|
421
420
|
if (observedProps.hasOwnProperty(propName)) {
|
|
422
|
-
var propValue =
|
|
421
|
+
var propValue = getProp(propName);
|
|
423
422
|
events.emit('propValue', propName, propValue);
|
|
424
423
|
observedProps[propName] = true;
|
|
425
424
|
}
|
|
426
425
|
}
|
|
427
|
-
|
|
426
|
+
function setProp(propName, propValue) {
|
|
428
427
|
switch (propName) {
|
|
429
428
|
case 'paused': {
|
|
430
429
|
if (stream !== null) {
|
|
@@ -443,10 +442,10 @@ function TizenVideo(options) {
|
|
|
443
442
|
|
|
444
443
|
// the paused state is usually correct, but i have seen it not change on tizen 3
|
|
445
444
|
// which causes all kinds of issues in the UI: (only happens with some videos)
|
|
446
|
-
var lastKnownProp =
|
|
445
|
+
var lastKnownProp = getProp('paused');
|
|
447
446
|
|
|
448
|
-
setTimeout(
|
|
449
|
-
if (
|
|
447
|
+
setTimeout(function() {
|
|
448
|
+
if (getProp('paused') !== lastKnownProp) {
|
|
450
449
|
onPropChanged('paused');
|
|
451
450
|
}
|
|
452
451
|
}, 1000);
|
|
@@ -471,7 +470,7 @@ function TizenVideo(options) {
|
|
|
471
470
|
return;
|
|
472
471
|
}
|
|
473
472
|
|
|
474
|
-
var subtitlesTracks =
|
|
473
|
+
var subtitlesTracks = getProp('subtitlesTracks');
|
|
475
474
|
var selectedSubtitlesTrack = subtitlesTracks
|
|
476
475
|
.find(function(track) {
|
|
477
476
|
return track.id === propValue;
|
|
@@ -575,13 +574,13 @@ function TizenVideo(options) {
|
|
|
575
574
|
if (stream !== null) {
|
|
576
575
|
currentAudioTrack = propValue;
|
|
577
576
|
|
|
578
|
-
var audioTracks =
|
|
577
|
+
var audioTracks = getProp('audioTracks');
|
|
579
578
|
var selectedAudioTrack = audioTracks
|
|
580
579
|
.find(function(track) {
|
|
581
580
|
return track.id === propValue;
|
|
582
581
|
});
|
|
583
582
|
|
|
584
|
-
if (
|
|
583
|
+
if (getProp('paused')) {
|
|
585
584
|
// issues before this logic:
|
|
586
585
|
// tizen 3 does not allow changing audio track when paused
|
|
587
586
|
// tizen 5 does, but it will only change getProp('selectedAudioTrackId') after playback starts
|
package/src/TizenVideo/AVPlay.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
const SCOPE = 'AVPlay';
|
|
2
|
-
|
|
3
|
-
const createAVPlay = (transport) => {
|
|
4
|
-
const getState = () => {
|
|
5
|
-
return transport.request(SCOPE, 'getState');
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const getCurrentTime = () => {
|
|
9
|
-
return transport.request(SCOPE, 'getCurrentTime');
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const getDuration = () => {
|
|
13
|
-
return transport.request(SCOPE, 'getDuration');
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const getTotalTrackInfo = () => {
|
|
17
|
-
return transport.request(SCOPE, 'getTotalTrackInfo');
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const getCurrentStreamInfo = () => {
|
|
21
|
-
return transport.request(SCOPE, 'getCurrentStreamInfo');
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const open = (path) => {
|
|
25
|
-
return transport.request(SCOPE, 'open', path);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const prepareAsync = async (successHandler, errorHandler) => {
|
|
29
|
-
const [handler, handlerResult] = await transport.request(SCOPE, 'prepareAsync', 'handler:success', 'handler:error');
|
|
30
|
-
if (handler === 'handler:success') successHandler();
|
|
31
|
-
if (handler === 'handler:error') errorHandler(...handlerResult);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const pause = () => {
|
|
35
|
-
return transport.request(SCOPE, 'pause');
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const play = () => {
|
|
39
|
-
return transport.request(SCOPE, 'play');
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const stop = () => {
|
|
43
|
-
return transport.request(SCOPE, 'stop');
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const seekTo = (time) => {
|
|
47
|
-
return transport.request(SCOPE, 'seekTo', time);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const setSpeed = (rate) => {
|
|
51
|
-
return transport.request(SCOPE, 'setSpeed', rate);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const setSelectTrack = (type, id) => {
|
|
55
|
-
return transport.request(SCOPE, 'setSelectTrack', type, id);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const setDisplayRect = (x, y, width, height) => {
|
|
59
|
-
return transport.request(SCOPE, 'setDisplayRect', x, y, width, height);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const setDisplayMethod = (method) => {
|
|
63
|
-
return transport.request(SCOPE, 'setDisplayMethod', method);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const setListener = (listener) => {
|
|
67
|
-
const handlers = Object.keys(listener).map((name) => `handler:${name}`);
|
|
68
|
-
const onHandlerResponse = (handler, handlerResult) => {
|
|
69
|
-
const name = handler.replace('handler:', '');
|
|
70
|
-
if (listener[name]) {
|
|
71
|
-
handlerResult ? listener[name](...handlerResult) : listener[name]();
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
transport.listen(SCOPE, 'setListener', onHandlerResponse, ...handlers);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
getState,
|
|
80
|
-
getCurrentTime,
|
|
81
|
-
getDuration,
|
|
82
|
-
getTotalTrackInfo,
|
|
83
|
-
getCurrentStreamInfo,
|
|
84
|
-
open,
|
|
85
|
-
prepareAsync,
|
|
86
|
-
pause,
|
|
87
|
-
play,
|
|
88
|
-
stop,
|
|
89
|
-
seekTo,
|
|
90
|
-
setSpeed,
|
|
91
|
-
setSelectTrack,
|
|
92
|
-
setDisplayRect,
|
|
93
|
-
setDisplayMethod,
|
|
94
|
-
setListener,
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
module.exports = createAVPlay;
|