@gcorevideo/player 2.14.1 → 2.15.0
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/dist/index.js +44 -4132
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/utils/mediaSources.d.ts.map +1 -1
- package/lib/utils/mediaSources.js +5 -3
- package/package.json +1 -1
- package/src/__tests__/Player.test.ts +2 -4
- package/src/index.ts +1 -1
- package/src/utils/__tests__/mediaSources.test.ts +8 -3
- package/src/utils/mediaSources.ts +3 -2
- package/tsconfig.tsbuildinfo +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC3D,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediaSources.d.ts","sourceRoot":"","sources":["../../src/utils/mediaSources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,UAAU,CAAA;AAGjB,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAA;IAClC,GAAG,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACjC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;CACrC,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,cAAc,CAiB5E;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,qBAAqB,EAAE,EAChC,iBAAiB,GAAE,mBAA4B,GAC9C,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"mediaSources.d.ts","sourceRoot":"","sources":["../../src/utils/mediaSources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,UAAU,CAAA;AAGjB,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAA;IAClC,GAAG,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACjC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;CACrC,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,cAAc,CAiB5E;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,qBAAqB,EAAE,EAChC,iBAAiB,GAAE,mBAA4B,GAC9C,qBAAqB,EAAE,CA6BzB;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAEzD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,iBAAiB,GAAG,qBAAqB,CAEtE;AAWD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,WAK7D;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,WAO5D"}
|
|
@@ -26,12 +26,14 @@ export function buildSourcesSet(sources) {
|
|
|
26
26
|
return sv;
|
|
27
27
|
}
|
|
28
28
|
export function buildMediaSourcesList(sources, priorityTransport = 'dash') {
|
|
29
|
-
const [preferred, rest] = sources.reduce(
|
|
29
|
+
const [preferred, rest] = sources.reduce(
|
|
30
|
+
// Always include HLS sources to enable HTML5 fallback
|
|
31
|
+
priorityTransport === 'dash'
|
|
30
32
|
? (acc, item) => {
|
|
31
33
|
if (canPlayDash(item.source, item.mimeType)) {
|
|
32
34
|
acc[0].push(item);
|
|
33
35
|
}
|
|
34
|
-
else {
|
|
36
|
+
else if (!isDashSource(item.source, item.mimeType)) {
|
|
35
37
|
acc[1].push(item);
|
|
36
38
|
}
|
|
37
39
|
return acc;
|
|
@@ -40,7 +42,7 @@ export function buildMediaSourcesList(sources, priorityTransport = 'dash') {
|
|
|
40
42
|
if (canPlayHls(item.source, item.mimeType)) {
|
|
41
43
|
acc[0].push(item);
|
|
42
44
|
}
|
|
43
|
-
else {
|
|
45
|
+
else if (!(isDashSource(item.source, item.mimeType) && !canPlayDash(item.source, item.mimeType))) {
|
|
44
46
|
acc[1].push(item);
|
|
45
47
|
}
|
|
46
48
|
return acc;
|
package/package.json
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
MockedObject,
|
|
8
8
|
vi,
|
|
9
9
|
} from 'vitest'
|
|
10
|
-
import FakeTimers from '@sinonjs/fake-timers'
|
|
11
10
|
import { LogTracer, Logger, setTracer } from '@gcorevideo/utils'
|
|
12
11
|
import { Loader, Player as PlayerClappr } from '@clappr/core'
|
|
13
12
|
import EventLite from 'event-lite'
|
|
@@ -15,7 +14,6 @@ import EventLite from 'event-lite'
|
|
|
15
14
|
import { Player } from '../Player'
|
|
16
15
|
import { TransportPreference } from '../types'
|
|
17
16
|
import { canPlayDash, canPlayHls } from '../playback'
|
|
18
|
-
import { PlaybackErrorCode } from '../playback.types'
|
|
19
17
|
import { isDashSource, isHlsSource } from '../utils/testUtils'
|
|
20
18
|
|
|
21
19
|
function createMockClapprPlayer(): MockedObject<typeof PlayerClappr> {
|
|
@@ -89,10 +87,10 @@ describe('Player', () => {
|
|
|
89
87
|
describe.each([
|
|
90
88
|
['dash', true, true, 'http://0eab.cdn.globo.com/1932-1447.mpd'],
|
|
91
89
|
['dash', false, true, 'http://0eab.cdn.globo.com/1932-1447.m3u8'],
|
|
92
|
-
['dash', false, false,
|
|
90
|
+
['dash', false, false, 'http://0eab.cdn.globo.com/1932-1447.m3u8'],
|
|
93
91
|
['hls', true, true, 'http://0eab.cdn.globo.com/1932-1447.m3u8'],
|
|
94
92
|
['hls', true, false, 'http://0eab.cdn.globo.com/1932-1447.mpd'],
|
|
95
|
-
['hls', false, false,
|
|
93
|
+
['hls', false, false, 'http://0eab.cdn.globo.com/1932-1447.m3u8'],
|
|
96
94
|
])(
|
|
97
95
|
' according to the preference (%s) and capabilities (dash=%s, hls=%s)',
|
|
98
96
|
(priority, dash, hls, source: string | undefined) => {
|
package/src/index.ts
CHANGED
|
@@ -155,6 +155,10 @@ describe('mediaSources', () => {
|
|
|
155
155
|
},
|
|
156
156
|
],
|
|
157
157
|
[
|
|
158
|
+
{ // HLS sources are always included to enable HTML5 fallback
|
|
159
|
+
source: 'http://example.com/video.m3u8',
|
|
160
|
+
mimeType: 'application/vnd.apple.mpegurl',
|
|
161
|
+
},
|
|
158
162
|
{
|
|
159
163
|
source: 'http://example.com/video.mpd',
|
|
160
164
|
mimeType: 'application/dash+xml',
|
|
@@ -163,6 +167,10 @@ describe('mediaSources', () => {
|
|
|
163
167
|
source: 'http://example.com/video2.mpd',
|
|
164
168
|
mimeType: 'application/dash+xml',
|
|
165
169
|
},
|
|
170
|
+
{
|
|
171
|
+
source: 'http://example.com/video3.m3u8',
|
|
172
|
+
mimeType: 'application/vnd.apple.mpegurl',
|
|
173
|
+
},
|
|
166
174
|
],
|
|
167
175
|
],
|
|
168
176
|
])('prefer %s, dash=%s,hls=%s', (preference, dash, hls, sources, expected) => {
|
|
@@ -174,9 +182,6 @@ describe('mediaSources', () => {
|
|
|
174
182
|
vi.mocked(canPlayHls).mockReturnValue(false)
|
|
175
183
|
}
|
|
176
184
|
})
|
|
177
|
-
// afterEach(() => {
|
|
178
|
-
// vi.mocked(canPlayDash)
|
|
179
|
-
// })
|
|
180
185
|
it('should build the ordered list of available sources', () => {
|
|
181
186
|
const ordered = buildMediaSourcesList(
|
|
182
187
|
sources,
|
|
@@ -41,6 +41,7 @@ export function buildMediaSourcesList(
|
|
|
41
41
|
priorityTransport: TransportPreference = 'dash',
|
|
42
42
|
): PlayerMediaSourceDesc[] {
|
|
43
43
|
const [preferred, rest] = sources.reduce(
|
|
44
|
+
// Always include HLS sources to enable HTML5 fallback
|
|
44
45
|
priorityTransport === 'dash'
|
|
45
46
|
? (
|
|
46
47
|
acc: [PlayerMediaSourceDesc[], PlayerMediaSourceDesc[]],
|
|
@@ -48,7 +49,7 @@ export function buildMediaSourcesList(
|
|
|
48
49
|
) => {
|
|
49
50
|
if (canPlayDash(item.source, item.mimeType)) {
|
|
50
51
|
acc[0].push(item)
|
|
51
|
-
} else {
|
|
52
|
+
} else if (!isDashSource(item.source, item.mimeType)) {
|
|
52
53
|
acc[1].push(item)
|
|
53
54
|
}
|
|
54
55
|
return acc
|
|
@@ -59,7 +60,7 @@ export function buildMediaSourcesList(
|
|
|
59
60
|
) => {
|
|
60
61
|
if (canPlayHls(item.source, item.mimeType)) {
|
|
61
62
|
acc[0].push(item)
|
|
62
|
-
} else {
|
|
63
|
+
} else if (!(isDashSource(item.source, item.mimeType) && !canPlayDash(item.source, item.mimeType))) {
|
|
63
64
|
acc[1].push(item)
|
|
64
65
|
}
|
|
65
66
|
return acc
|