Skip to content

Commit 15ecab4

Browse files
committed
Fix ordering of sources
1 parent e9b6426 commit 15ecab4

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

video/src/Video.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,23 @@ const Video = ({
211211
>
212212
{video &&
213213
video.sources &&
214-
video.sources
215-
.sort((v) => (v.format === 'video/webm' ? -1 : 1))
214+
video.sources
215+
.sort((a, b) => {
216+
217+
if (a.format === b.format) return 0;
218+
if (a.format === 'video/quicktime') return -1;
219+
if (b.format === 'video/quicktime') return 1;
220+
221+
if (a.format === 'video/mp4') return -1;
222+
if (b.format === 'video/mp4') return 1;
223+
224+
if (a.format === 'video/webm') return -1;
225+
if (b.format === 'video/webm') return 1;
226+
227+
if (a.format === 'video/ogg') return -1;
228+
if (b.format === 'video/ogg') return 1;
229+
return 0;
230+
})
216231
.map((v) => <source key={v.url} src={v.url} type={v.format || 'video/mp4'} />)}
217232
<p>{altText || 'Your browser does not support this video'}</p>
218233
</video>

0 commit comments

Comments
 (0)