@amazon/vinyl 4.0.0 → 4.0.1-next.20261016184530

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.
Files changed (76) hide show
  1. package/dist/index.cjs +40 -3
  2. package/dist/index.cjs.map +2 -2
  3. package/dist/index.js +41 -3
  4. package/dist/index.js.map +2 -2
  5. package/dist/test/benchmark.es5.js +5 -4
  6. package/dist/test/benchmark.js +11 -2
  7. package/dist/test/benchmark.js.map +3 -3
  8. package/dist/test/errata/mse-changetype-sequence.html +65 -0
  9. package/dist/test/errata/mse-changetype-sequence.js +179 -0
  10. package/dist/test/index.html +2 -2
  11. package/dist/test/integ.es5.js +287 -276
  12. package/dist/test/integ.js +629 -245
  13. package/dist/test/integ.js.map +4 -4
  14. package/dist/test/styles.css +23 -13
  15. package/dist/types/current/playback/PlaybackControllerImpl.d.ts +12 -0
  16. package/dist/types/current/playback/PlaybackControllerImpl.d.ts.map +1 -1
  17. package/dist/types/current/playback/PlaybackControllerImpl.js +42 -1
  18. package/dist/types/current/streaming/buffering/BufferingController.d.ts.map +1 -1
  19. package/dist/types/current/streaming/buffering/BufferingController.js +9 -2
  20. package/dist/types/current/streaming/buffering/MediaSourceController.d.ts.map +1 -1
  21. package/dist/types/current/streaming/buffering/MediaSourceController.js +4 -2
  22. package/dist/types/current/tsconfig.tsbuildinfo +1 -1
  23. package/dist/types/ts3.7/playback/PlaybackControllerImpl.d.ts +12 -0
  24. package/dist/types/ts4.1/playback/PlaybackControllerImpl.d.ts +12 -0
  25. package/dist/types/ts4.7/playback/PlaybackControllerImpl.d.ts +12 -0
  26. package/dist/unit/types/current/playback/PlaybackControllerImpl.test.js +86 -0
  27. package/dist/unit/types/current/setup.js +6 -5
  28. package/dist/unit/types/current/streaming/SegmentControllerImpl.test.js +44 -1
  29. package/dist/unit/types/current/streaming/buffering/BufferingController.test.js +14 -0
  30. package/dist/unit/types/current/streaming/buffering/MediaSourceController.test.js +13 -0
  31. package/dist/unit/types/current/track/dash/createDashFactories.test.js +15 -5
  32. package/dist/unit/types/current/track/hls/createHlsFactories.test.js +36 -12
  33. package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
  34. package/dist/unit/types/current/vinyl/VinylPlayerAdBreaks.test.js +8 -5
  35. package/dist/vinylTestUtil/index.js +92 -60
  36. package/dist/vinylTestUtil/index.js.map +4 -4
  37. package/dist/vinylTestUtil/types/current/media/FrequencyAnalyzer.d.ts +8 -5
  38. package/dist/vinylTestUtil/types/current/media/FrequencyAnalyzer.d.ts.map +1 -1
  39. package/dist/vinylTestUtil/types/current/media/FrequencyAnalyzer.js +23 -29
  40. package/dist/vinylTestUtil/types/current/media/unlockMediaElement.d.ts +10 -1
  41. package/dist/vinylTestUtil/types/current/media/unlockMediaElement.d.ts.map +1 -1
  42. package/dist/vinylTestUtil/types/current/media/unlockMediaElement.js +34 -6
  43. package/dist/vinylTestUtil/types/current/player/createVinylSuite.d.ts.map +1 -1
  44. package/dist/vinylTestUtil/types/current/player/createVinylSuite.js +6 -1
  45. package/dist/vinylTestUtil/types/current/player/mediaRef.d.ts +7 -0
  46. package/dist/vinylTestUtil/types/current/player/mediaRef.d.ts.map +1 -1
  47. package/dist/vinylTestUtil/types/current/player/mediaRef.js +8 -1
  48. package/dist/vinylTestUtil/types/current/tsconfig.tsbuildinfo +1 -1
  49. package/dist/vinylTestUtil/types/current/ui/requireUserInteraction.d.ts +6 -2
  50. package/dist/vinylTestUtil/types/current/ui/requireUserInteraction.d.ts.map +1 -1
  51. package/dist/vinylTestUtil/types/current/ui/requireUserInteraction.js +31 -15
  52. package/dist/vinylTestUtil/types/current/util/playback/expectTrackPlays.d.ts +9 -2
  53. package/dist/vinylTestUtil/types/current/util/playback/expectTrackPlays.d.ts.map +1 -1
  54. package/dist/vinylTestUtil/types/current/util/playback/expectTrackPlays.js +10 -7
  55. package/dist/vinylTestUtil/types/current/util/playback/expectTrackPlaysUntil.d.ts +4 -1
  56. package/dist/vinylTestUtil/types/current/util/playback/expectTrackPlaysUntil.d.ts.map +1 -1
  57. package/dist/vinylTestUtil/types/current/util/playback/expectTrackPlaysUntil.js +3 -2
  58. package/dist/vinylTestUtil/types/ts3.7/media/FrequencyAnalyzer.d.ts +8 -5
  59. package/dist/vinylTestUtil/types/ts3.7/media/unlockMediaElement.d.ts +10 -1
  60. package/dist/vinylTestUtil/types/ts3.7/player/mediaRef.d.ts +7 -0
  61. package/dist/vinylTestUtil/types/ts3.7/ui/requireUserInteraction.d.ts +6 -2
  62. package/dist/vinylTestUtil/types/ts3.7/util/playback/expectTrackPlays.d.ts +9 -2
  63. package/dist/vinylTestUtil/types/ts3.7/util/playback/expectTrackPlaysUntil.d.ts +4 -1
  64. package/dist/vinylTestUtil/types/ts4.1/media/FrequencyAnalyzer.d.ts +8 -5
  65. package/dist/vinylTestUtil/types/ts4.1/media/unlockMediaElement.d.ts +10 -1
  66. package/dist/vinylTestUtil/types/ts4.1/player/mediaRef.d.ts +7 -0
  67. package/dist/vinylTestUtil/types/ts4.1/ui/requireUserInteraction.d.ts +6 -2
  68. package/dist/vinylTestUtil/types/ts4.1/util/playback/expectTrackPlays.d.ts +9 -2
  69. package/dist/vinylTestUtil/types/ts4.1/util/playback/expectTrackPlaysUntil.d.ts +4 -1
  70. package/dist/vinylTestUtil/types/ts4.7/media/FrequencyAnalyzer.d.ts +8 -5
  71. package/dist/vinylTestUtil/types/ts4.7/media/unlockMediaElement.d.ts +10 -1
  72. package/dist/vinylTestUtil/types/ts4.7/player/mediaRef.d.ts +7 -0
  73. package/dist/vinylTestUtil/types/ts4.7/ui/requireUserInteraction.d.ts +6 -2
  74. package/dist/vinylTestUtil/types/ts4.7/util/playback/expectTrackPlays.d.ts +9 -2
  75. package/dist/vinylTestUtil/types/ts4.7/util/playback/expectTrackPlaysUntil.d.ts +4 -1
  76. package/package.json +11 -10
@@ -0,0 +1,65 @@
1
+ <!doctype html>
2
+ <!--
3
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ SPDX-License-Identifier: Apache-2.0
5
+ -->
6
+ <html lang="en">
7
+ <head>
8
+ <meta charset="utf-8" />
9
+ <title>MSE changeType() in sequence mode</title>
10
+ </head>
11
+ <body>
12
+ <h1>MSE changeType() in sequence mode</h1>
13
+ <p>
14
+ Appends two 2 s segments in "sequence" mode, calls changeType() to
15
+ another codec, then appends a segment whose media time is 38 s. Per
16
+ the
17
+ <a
18
+ href="https://w3c.github.io/media-source/#sourcebuffer-reset-parser-state"
19
+ >reset parser state algorithm</a
20
+ >, the segment continues the buffered media: buffered is [0, 6].
21
+ WebKit leaves a gap:
22
+ <a href="https://bugs.webkit.org/show_bug.cgi?id=327788"
23
+ >WebKit bug 327788</a
24
+ >.
25
+ </p>
26
+ <p>
27
+ Serve this directory over HTTP (e.g.
28
+ <code>python3 -m http.server</code>); the segments are fetched from
29
+ assets.dev.vinyl.music.amazon.dev.
30
+ </p>
31
+ <p id="result">Running…</p>
32
+ <ol id="steps"></ol>
33
+ <pre id="details"></pre>
34
+ <script src="mse-changetype-sequence.js"></script>
35
+ <script>
36
+ var resultElement = document.getElementById('result')
37
+ if (location.protocol === 'file:') {
38
+ resultElement.textContent =
39
+ 'Running… Opened from file://, where Safari never opens the MediaSource (sourceopen times out); serve this directory over HTTP.'
40
+ }
41
+ window
42
+ .runChangeTypeSequenceRepro(function (name) {
43
+ var item = document.createElement('li')
44
+ item.textContent = name
45
+ document.getElementById('steps').append(item)
46
+ })
47
+ .then(function (result) {
48
+ resultElement.textContent = !result.supported
49
+ ? 'UNSUPPORTED: changeType() or the codecs are not supported.'
50
+ : result.contiguous
51
+ ? 'PASS: the segment after changeType() continues the buffered media.'
52
+ : 'FAIL: the segment after changeType() was appended at its media time, leaving a gap.'
53
+ document.getElementById('details').textContent =
54
+ navigator.userAgent +
55
+ '\n' +
56
+ JSON.stringify(result, null, 2)
57
+ })
58
+ .catch(function (error) {
59
+ resultElement.textContent = 'ERROR: ' + error
60
+ document.getElementById('details').textContent =
61
+ navigator.userAgent
62
+ })
63
+ </script>
64
+ </body>
65
+ </html>
@@ -0,0 +1,179 @@
1
+ /*
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /*
7
+ * Test bed: MSE changeType() in "sequence" mode.
8
+ *
9
+ * changeType() runs the reset parser state algorithm, which in "sequence" mode sets [[group start timestamp]] to
10
+ * [[group end timestamp]] (https://w3c.github.io/media-source/#sourcebuffer-reset-parser-state), so the next media
11
+ * segment is appended right after the buffered media whatever its timestamps. This appends two 2 s segments, changes
12
+ * type to another codec, then appends a segment whose media time is 38 s. Per the spec the buffer is [0, 6]. WebKit
13
+ * leaves it at [0, 4] and [38, 40]: https://bugs.webkit.org/show_bug.cgi?id=327788
14
+ *
15
+ * Used by testResources/errata/mse-changetype-sequence.html and the vinyl errata integ spec.
16
+ */
17
+ ;(function () {
18
+ var BASE =
19
+ 'https://assets.dev.vinyl.music.amazon.dev/dash/vinyl_ad_breaks_av/segments/'
20
+ var FIRST = {
21
+ dir: BASE + 'libx264_640x360_30fps_600k/',
22
+ type: 'video/mp4; codecs="avc1.64001e"',
23
+ }
24
+ var SECOND = {
25
+ dir: BASE + 'libx264_1280x720_30fps_1500k/',
26
+ type: 'video/mp4; codecs="avc1.64001f"',
27
+ }
28
+
29
+ var STEP_TIMEOUT_MS = 15000
30
+
31
+ /** Rejects if the promise doesn't settle in time, so a stalled step is reported rather than hanging. */
32
+ function step(onStep, name, promise) {
33
+ onStep(name)
34
+ return new Promise(function (resolve, reject) {
35
+ var timer = setTimeout(function () {
36
+ reject(
37
+ new Error(
38
+ 'timed out after ' +
39
+ STEP_TIMEOUT_MS / 1000 +
40
+ ' s: ' +
41
+ name
42
+ )
43
+ )
44
+ }, STEP_TIMEOUT_MS)
45
+ promise.then(
46
+ function (value) {
47
+ clearTimeout(timer)
48
+ resolve(value)
49
+ },
50
+ function (error) {
51
+ clearTimeout(timer)
52
+ reject(error)
53
+ }
54
+ )
55
+ })
56
+ }
57
+
58
+ function fetchBuffer(url) {
59
+ return fetch(url).then(function (response) {
60
+ if (!response.ok) throw new Error(response.status + ' ' + url)
61
+ return response.arrayBuffer()
62
+ })
63
+ }
64
+
65
+ function append(sourceBuffer, data) {
66
+ return new Promise(function (resolve, reject) {
67
+ function done() {
68
+ sourceBuffer.removeEventListener('error', fail)
69
+ resolve()
70
+ }
71
+ function fail() {
72
+ sourceBuffer.removeEventListener('updateend', done)
73
+ reject(new Error('append error'))
74
+ }
75
+ sourceBuffer.addEventListener('updateend', done, { once: true })
76
+ sourceBuffer.addEventListener('error', fail, { once: true })
77
+ sourceBuffer.appendBuffer(data)
78
+ })
79
+ }
80
+
81
+ function ranges(sourceBuffer) {
82
+ var result = []
83
+ for (var i = 0; i < sourceBuffer.buffered.length; i++) {
84
+ result.push([
85
+ Math.round(sourceBuffer.buffered.start(i) * 100) / 100,
86
+ Math.round(sourceBuffer.buffered.end(i) * 100) / 100,
87
+ ])
88
+ }
89
+ return result
90
+ }
91
+
92
+ /**
93
+ * Resolves to { supported, contiguous, before, after, timestampOffset }.
94
+ * `contiguous` is true when the browser follows the spec. Rejects if a step times out.
95
+ *
96
+ * @param onStep Called with the name of each step as it starts.
97
+ */
98
+ window.runChangeTypeSequenceRepro = async function (onStep) {
99
+ onStep = onStep || function () {}
100
+ if (
101
+ typeof MediaSource === 'undefined' ||
102
+ !('changeType' in SourceBuffer.prototype) ||
103
+ !MediaSource.isTypeSupported(FIRST.type) ||
104
+ !MediaSource.isTypeSupported(SECOND.type)
105
+ ) {
106
+ return { supported: false }
107
+ }
108
+ var buffers = await step(
109
+ onStep,
110
+ 'fetch segments',
111
+ Promise.all([
112
+ fetchBuffer(FIRST.dir + 'init.mp4'),
113
+ fetchBuffer(FIRST.dir + 'part_1.m4s'),
114
+ fetchBuffer(FIRST.dir + 'part_2.m4s'),
115
+ fetchBuffer(SECOND.dir + 'init.mp4'),
116
+ fetchBuffer(SECOND.dir + 'part_20.m4s'),
117
+ ])
118
+ )
119
+ var mediaSource = new MediaSource()
120
+ var media = document.createElement('video')
121
+ var url = URL.createObjectURL(mediaSource)
122
+ media.muted = true
123
+ media.src = url
124
+ try {
125
+ await step(
126
+ onStep,
127
+ 'sourceopen',
128
+ new Promise(function (resolve) {
129
+ mediaSource.addEventListener('sourceopen', resolve, {
130
+ once: true,
131
+ })
132
+ })
133
+ )
134
+ var sourceBuffer = mediaSource.addSourceBuffer(FIRST.type)
135
+ sourceBuffer.mode = 'sequence'
136
+ await step(
137
+ onStep,
138
+ 'append ' + FIRST.type + ' init',
139
+ append(sourceBuffer, buffers[0])
140
+ )
141
+ await step(
142
+ onStep,
143
+ 'append part_1',
144
+ append(sourceBuffer, buffers[1])
145
+ )
146
+ await step(
147
+ onStep,
148
+ 'append part_2',
149
+ append(sourceBuffer, buffers[2])
150
+ )
151
+ var before = ranges(sourceBuffer)
152
+ onStep('changeType(' + SECOND.type + ')')
153
+ sourceBuffer.changeType(SECOND.type)
154
+ await step(
155
+ onStep,
156
+ 'append ' + SECOND.type + ' init',
157
+ append(sourceBuffer, buffers[3])
158
+ )
159
+ await step(
160
+ onStep,
161
+ 'append part_20',
162
+ append(sourceBuffer, buffers[4])
163
+ )
164
+ var after = ranges(sourceBuffer)
165
+ return {
166
+ supported: true,
167
+ contiguous: after.length === 1 && after[0][0] === before[0][0],
168
+ before: before,
169
+ after: after,
170
+ timestampOffset:
171
+ Math.round(sourceBuffer.timestampOffset * 100) / 100,
172
+ }
173
+ } finally {
174
+ media.removeAttribute('src')
175
+ media.load()
176
+ URL.revokeObjectURL(url)
177
+ }
178
+ }
179
+ })()
@@ -54,8 +54,8 @@
54
54
  </head>
55
55
 
56
56
  <body>
57
- <div class="callout" id="unlockAudioPrompt" style="display: none">
58
- <div class="instructions">Press any key or click to begin.</div>
57
+ <div class="startPrompt" id="unlockAudioPrompt" style="display: none">
58
+ <button class="startButton" type="button">Click to start</button>
59
59
  </div>
60
60
  </body>
61
61
  </html>