Skip to content

Commit 34891f0

Browse files
authored
fix: recognize Opus audio sources by extension (#1865)
1 parent fefe1eb commit 34891f0

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎packages/vidstack/src/utils/mime.test.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
import { canGoogleCastSrc } from './mime';
1+
import { canGoogleCastSrc, isAudioSrc } from './mime';
2+
3+
describe(isAudioSrc.name, function () {
4+
it('recognizes an Opus file without relying on its server MIME type', function () {
5+
expect(
6+
isAudioSrc({
7+
src: 'https://example.com/recording.opus?download=1',
8+
type: '?',
9+
}),
10+
).to.equal(true);
11+
});
12+
});
213

314
describe(canGoogleCastSrc.name, function () {
415
it('accepts DASH sources by type', function () {

‎packages/vidstack/src/utils/mime.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { canPlayHLSNatively } from './support';
55

66
// https://github.com/cookpete/react-player/blob/master/src/patterns.js#L16
77
export const AUDIO_EXTENSIONS =
8-
/\.(m4a|m4b|mp4a|mpga|mp2|mp2a|mp3|m2a|m3a|wav|weba|aac|oga|spx|flac)($|\?)/i;
8+
/\.(m4a|m4b|mp4a|mpga|mp2|mp2a|mp3|m2a|m3a|wav|weba|aac|oga|opus|spx|flac)($|\?)/i;
99

1010
// TODO: We'll need to extend this later.
1111
export const AUDIO_TYPES = new Set<string>([

0 commit comments

Comments
 (0)