Skip to content

Commit

Permalink
Add web player for audio objects (#3098)
Browse files Browse the repository at this point in the history
  • Loading branch information
yifanmai authored Oct 27, 2024
1 parent a618a01 commit 2a16c51
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions helm-frontend/src/components/MediaObjectDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ export default function MediaObjectDisplay({ mediaObject }: Props) {
<br />
</div>
);
} else if (mediaObject.content_type.includes("audio")) {
if (mediaObject.location === undefined) {
return null;
}
const url = getBenchmarkEndpoint(
mediaObject.location
.replace("benchmark_output/", "")
.replace("prod_env/", "../"),
);
return (
<div>
<audio controls src={url}></audio>
</div>
);
} else {
if (
mediaObject.text &&
Expand Down
3 changes: 3 additions & 0 deletions helm-frontend/src/utils/getBenchmarkEndpoint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export default function getBenchmarkEndpoint(path: string): string {
if (path.startsWith("http://") || path.startsWith("https://")) {
return path;
}
return `${window.BENCHMARK_OUTPUT_BASE_URL.replace(/\/$/, "")}/${path.replace(
/^\//,
"",
Expand Down

0 comments on commit 2a16c51

Please sign in to comment.