Skip to content

Commit

Permalink
Support a variety of HLS formats.
Browse files Browse the repository at this point in the history
Closes #197
  • Loading branch information
tpendragon committed Apr 17, 2024
1 parent d03e50f commit 937a01c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/Viewer/Player/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { LabeledIIIFExternalWebResource } from "src/types/presentation-3";
import { PlayerWrapper } from "src/components/Viewer/Player/Player.styled";
import Track from "src/components/Viewer/Player/Track";
import { getPaintingResource } from "src/hooks/use-iiif";
import { hlsMimeTypes } from "src/lib/hls";

// Set referrer header as a NU domain: ie. meadow.rdc-staging.library.northwestern.edu

Expand Down Expand Up @@ -51,8 +52,14 @@ const Player: React.FC<PlayerProps> = ({
/**
* Eject HLS attachment if file extension from
* the IIIF content resource ID is not .m3u8
* and format is not one of many m3u8 formats.
*/
if (painting.id.split(".").pop() !== "m3u8") return;
if (
painting.id.split(".").pop() !== "m3u8" &&
painting.format &&
!hlsMimeTypes.includes(painting.format)
)
return;

// Construct HLS.js config
const config = {
Expand Down
15 changes: 15 additions & 0 deletions src/lib/hls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const hlsMimeTypes = [
// Apple santioned
"application/vnd.apple.mpegurl",
"vnd.apple.mpegurl",
// Apple sanctioned for backwards compatibility
"audio/mpegurl",
// Very common
"audio/x-mpegurl",
// Very common
"application/x-mpegurl",
// Included for completeness
"video/x-mpegurl",
"video/mpegurl",
"application/mpegurl",
];

0 comments on commit 937a01c

Please sign in to comment.