Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#5519 from ConnectAI-E/feature-play-…
Browse files Browse the repository at this point in the history
…audio-and-video

Feature play audio and video
  • Loading branch information
Dogtiti authored Sep 24, 2024
2 parents 649c5be + dbabb2c commit 9bbd7d3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/components/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@ function _MarkDownContent(props: { content: string }) {
p: (pProps) => <p {...pProps} dir="auto" />,
a: (aProps) => {
const href = aProps.href || "";
if (/\.(aac|mp3|opus|wav)$/.test(href)) {
return (
<figure>
<audio controls src={href}></audio>
</figure>
);
}
if (/\.(3gp|3g2|webm|ogv|mpeg|mp4|avi)$/.test(href)) {
return (
<video controls width="99.9%">
<source src={href} />
</video>
);
}
const isInternal = /^\/#/i.test(href);
const target = isInternal ? "_self" : aProps.target ?? "_blank";
return <a {...aProps} target={target} />;
Expand Down

0 comments on commit 9bbd7d3

Please sign in to comment.