Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@profullstack/player",
"version": "0.3.0",
"version": "0.3.1",
"description": "One web player for every source a Profullstack site serves: MP4, HLS, MPEG-2 transport streams and audio, with one control bar, on desktop, mobile, PWA and television.",
"keywords": [
"video",
Expand Down
7 changes: 6 additions & 1 deletion src/engines/codecs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ export function codecName(codec: string | null | undefined): string | null {
* handed is the one that has to pass, and only that one is ever true here anyway.
*/
export function mseCandidates(kind: 'video' | 'audio', codec: string | undefined): string[] {
if (!codec) return [];
// `kind` is typed, and that protects TypeScript callers only. This module is
// imported by two plain-JavaScript client bundles where a missing kind is an
// ordinary runtime value, and the original guarded both -- dropping it in the
// port turned `mseCandidates(null, 'mp3')` from "nothing to ask" into a
// question about `null/mp4`. Caught by genrewatch's own suite on adoption.
if (!codec || !kind) return [];

if (kind === 'audio') {
/*
Expand Down
6 changes: 5 additions & 1 deletion test/codecs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ describe('mseCandidates', () => {
expect(mseCandidates('audio', 'ac-3')).toEqual(['audio/mp4; codecs="ac-3"']);
});

it('has nothing to ask when there is no codec', () => {
it('has nothing to ask when there is no codec, or no kind', () => {
expect(mseCandidates('audio', undefined)).toEqual([]);
// Regression: `kind` is typed, which protects TypeScript callers and not
// the two JavaScript bundles that import this. Without the runtime guard,
// a missing kind asked MSE about `null/mp4`.
expect(mseCandidates(null as unknown as 'audio', 'mp3')).toEqual([]);
});
});

Expand Down
Loading