expo-video-subtitle 0.7.4 → 0.7.5
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/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,34 @@ Changes inherited from the upstream base version are not repeated here — see t
|
|
|
7
7
|
[upstream changelog](https://github.com/expo/expo/blob/main/packages/expo-video/CHANGELOG.md)
|
|
8
8
|
for the history of everything that isn't subtitle related.
|
|
9
9
|
|
|
10
|
+
## 0.7.5
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **One episode's signs drew over the next one.** Opening episode 4 after episode 3 kept episode 3's
|
|
15
|
+
typesetting on screen for the whole runtime.
|
|
16
|
+
|
|
17
|
+
The cause was insurance added in 0.7.3 that turned into the bug it was insuring against.
|
|
18
|
+
`AssSignStore.get` answered a missed track id with "the only script on hand", to protect against
|
|
19
|
+
the parser and the overlay disagreeing about `Format.id`. They do not disagree — a device run
|
|
20
|
+
confirmed both name the same track — and the fallback fired in a case that was never considered:
|
|
21
|
+
a new episode misses on its own id for the first twelve seconds, while its 2.7 MB file is still
|
|
22
|
+
parsing, and the only script on hand is the previous episode's. Once resolved, the overlay stops
|
|
23
|
+
looking for a better one, so it never corrected itself.
|
|
24
|
+
|
|
25
|
+
A miss is now a miss. It means "not parsed yet", which the overlay already polls through.
|
|
26
|
+
|
|
27
|
+
- **A track change is noticed without waiting to be told.** The overlay re-resolved only when it had
|
|
28
|
+
no script at all, so it leaned on `onTracksChanged` to catch a switch. It now compares the track
|
|
29
|
+
its script came from against the one currently selected, four times a second, and re-resolves when
|
|
30
|
+
they differ.
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- The store keeps two tracks rather than four. That covers switching language within an episode and
|
|
35
|
+
moving to the next one, and each entry holds every sign in an episode — 12,616 in the file this
|
|
36
|
+
was built against.
|
|
37
|
+
|
|
10
38
|
## 0.7.4
|
|
11
39
|
|
|
12
40
|
Signs render. This is the release where the feature added in 0.7.0 actually reaches the screen.
|
|
@@ -55,6 +55,8 @@ internal class AssSignOverlay(context: Context) : View(context), Player.Listener
|
|
|
55
55
|
|
|
56
56
|
private var player: Player? = null
|
|
57
57
|
private var script: AssScript? = null
|
|
58
|
+
/** The track [script] belongs to, so a change of track is noticed even mid-poll. */
|
|
59
|
+
private var scriptTrackId: String? = null
|
|
58
60
|
|
|
59
61
|
private var active: List<AssSign> = emptyList()
|
|
60
62
|
private var prepared: List<PreparedSign> = emptyList()
|
|
@@ -93,6 +95,7 @@ internal class AssSignOverlay(context: Context) : View(context), Player.Listener
|
|
|
93
95
|
player?.removeListener(this)
|
|
94
96
|
player = null
|
|
95
97
|
script = null
|
|
98
|
+
scriptTrackId = null
|
|
96
99
|
layouts = HashMap()
|
|
97
100
|
setActive(emptyList())
|
|
98
101
|
}
|
|
@@ -105,6 +108,7 @@ internal class AssSignOverlay(context: Context) : View(context), Player.Listener
|
|
|
105
108
|
private fun resolveScript() {
|
|
106
109
|
val trackId = selectedTextTrackId()
|
|
107
110
|
val next = AssSignStore.get(trackId)
|
|
111
|
+
scriptTrackId = trackId
|
|
108
112
|
if (next === script) return
|
|
109
113
|
// The one line worth keeping. Every failure of this subsystem has been silent — a span dropped
|
|
110
114
|
// by Parcel, a timestamp rejected, a loop that never started — and each time this line would
|
|
@@ -169,17 +173,23 @@ internal class AssSignOverlay(context: Context) : View(context), Player.Listener
|
|
|
169
173
|
private fun tick() {
|
|
170
174
|
val player = this.player ?: return
|
|
171
175
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
// Polled rather than waited for, on two counts.
|
|
177
|
+
//
|
|
178
|
+
// A script arrives late: the parser runs on another thread whenever the file finishes
|
|
179
|
+
// downloading — about twelve seconds on a 2.7 MB script — and nothing in Media3 announces "a
|
|
180
|
+
// subtitle has been parsed". The cue stream would have, which is exactly what this design gave
|
|
181
|
+
// up.
|
|
182
|
+
//
|
|
183
|
+
// And the track changes underneath: moving to the next episode swaps the selected text track,
|
|
184
|
+
// and `onTracksChanged` is not something to stake the whole feature on. Comparing the track this
|
|
185
|
+
// script came from against the one selected now catches it either way — without that, episode
|
|
186
|
+
// three's signs kept drawing over episode four.
|
|
187
|
+
val now = SystemClock.uptimeMillis()
|
|
188
|
+
if (now - lastLookupMs >= LOOKUP_INTERVAL_MS) {
|
|
179
189
|
lastLookupMs = now
|
|
180
|
-
resolveScript()
|
|
181
|
-
if (script == null) return
|
|
190
|
+
if (script == null || selectedTextTrackId() != scriptTrackId) resolveScript()
|
|
182
191
|
}
|
|
192
|
+
if (script == null) return
|
|
183
193
|
|
|
184
194
|
val script = this.script ?: return
|
|
185
195
|
val positionUs = player.contentPosition * 1000L
|
|
@@ -30,11 +30,11 @@ package expo.modules.video.utils
|
|
|
30
30
|
internal object AssSignStore {
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
* every sign in an episode — 12,616 in the file this
|
|
35
|
-
* let grow.
|
|
33
|
+
* The track being watched plus the one before it, which covers switching language mid-episode and
|
|
34
|
+
* moving to the next episode. Each entry holds every sign in an episode — 12,616 in the file this
|
|
35
|
+
* was built against — so this is not a cache to let grow.
|
|
36
36
|
*/
|
|
37
|
-
private const val MAX_TRACKS =
|
|
37
|
+
private const val MAX_TRACKS = 2
|
|
38
38
|
|
|
39
39
|
private val scripts = object : LinkedHashMap<String, AssScript>(MAX_TRACKS, 0.75f, true) {
|
|
40
40
|
override fun removeEldestEntry(eldest: MutableMap.MutableEntry<String, AssScript>): Boolean =
|
|
@@ -48,20 +48,20 @@ internal object AssSignStore {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* Strictly by id. A miss is a miss.
|
|
52
52
|
*
|
|
53
|
-
*
|
|
54
|
-
* from different places
|
|
55
|
-
* the
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
53
|
+
* This used to fall back to the only script on hand, as insurance against the two ends reading
|
|
54
|
+
* `Format.id` from different places and disagreeing. They do not disagree — the device confirmed
|
|
55
|
+
* the parser and the overlay name the same track — and the insurance turned out to be a bug of its
|
|
56
|
+
* own: opening a second episode misses on the new id, and "the only script on hand" is the
|
|
57
|
+
* *previous* episode's. Its signs then draw over the new one for its whole runtime, because a
|
|
58
|
+
* resolved script stops the overlay from looking again.
|
|
59
|
+
*
|
|
60
|
+
* A miss here is not a failure. It means the file has not finished parsing yet, which on a 2.7 MB
|
|
61
|
+
* script takes about twelve seconds, and the overlay polls until it has.
|
|
59
62
|
*/
|
|
60
63
|
@Synchronized
|
|
61
|
-
fun get(trackId: String?): AssScript? {
|
|
62
|
-
scripts[trackId]?.let { return it }
|
|
63
|
-
return scripts.values.singleOrNull()
|
|
64
|
-
}
|
|
64
|
+
fun get(trackId: String?): AssScript? = trackId?.let { scripts[it] }
|
|
65
65
|
|
|
66
66
|
@Synchronized
|
|
67
67
|
fun clear() {
|
package/package.json
CHANGED