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: 0 additions & 2 deletions __tests__/mimeCoverage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ const NOT_COVERED_HERE: Record<string, string> = {
// so a fixture would only record which browser ran the suite
'audio/aacp': 'Chromium reports it cannot play this',
'audio/vorbis': 'not a type any encoder writes; ogg carries vorbis',
'video/mpeg': 'no engine decodes MPEG-1/2 video',
'video/x-flv': 'no engine decodes Flash video',
'video/quicktime': 'decoding depends on the codecs inside the container',
'video/x-m4v': 'decoding depends on the codecs inside the container',
'video/x-matroska': 'aliased to webm; decoding depends on the codecs inside',
Expand Down
9 changes: 7 additions & 2 deletions __tests__/models.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,10 @@ describe('the custom elements', () => {

describe('videos model', () => {
it.each([
'video/mpeg',
'video/ogg',
'video/webm',
'video/mp4',
'video/x-m4v',
'video/x-flv',
'video/quicktime',
])('enables browser-supported mime %s', async (mime) => {
const { registerVideoHandler } = await import('../lib/models/videos.ts')
Expand All @@ -97,6 +95,13 @@ describe('videos model', () => {
expect(handler.enabled([makeFile({ mime })])).toBe(true)
})

// Neither Chromium nor Firefox reads these: the file downloads instead
it.each(['video/mpeg', 'video/x-flv'])('leaves %s to the download', async (mime) => {
const { registerVideoHandler } = await import('../lib/models/videos.ts')
registerVideoHandler()
expect(handlerById('videos').enabled([makeFile({ mime })])).toBe(false)
})

it('enables the aliased mime video/x-matroska (maps to video/webm)', async () => {
const { registerVideoHandler } = await import('../lib/models/videos.ts')
registerVideoHandler()
Expand Down
4 changes: 4 additions & 0 deletions lib/models/audios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { logger } from '../services/logger.ts'
import { defineCustomElementOnce } from '../utils/customElements.ts'
import { t } from '../utils/l10n.ts'

/**
* Mimes a file can carry, as the server assigns them or a remote storage
* reports them, whose format a browser plays on its own.
*/
export const browserSupportedMimes = [
'audio/aac',
'audio/aacp',
Expand Down
9 changes: 7 additions & 2 deletions lib/models/videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ import { logger } from '../services/logger.ts'
import { defineCustomElementOnce } from '../utils/customElements.ts'
import { t } from '../utils/l10n.ts'

/**
* Mimes a file can carry, as the server assigns them or a remote storage
* reports them, whose format a browser plays on its own. Not what
* `canPlayType` answers: a QuickTime file holding H.264 plays in Chromium,
* which still says it cannot. MPEG-1/2 (`video/mpeg`) and Flash video
* (`video/x-flv`) are left out, as neither Chromium nor Firefox reads them.
*/
export const browserSupportedMimes = [
'video/mpeg',
'video/ogg',
'video/webm',
'video/mp4',
'video/x-m4v',
'video/x-flv',
'video/quicktime',
]

Expand Down
Loading