Skip to content

Commit

Permalink
Feat: Support custom streamUrl in Demo component (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaDemchenko authored Sep 23, 2024
1 parent 353317e commit fb5300b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 8 additions & 1 deletion demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import "./app.css";
import { P2PVideoDemo } from "p2p-media-loader-demo";

function App() {
return <P2PVideoDemo debugToolsEnabled={false} />;
return (
<P2PVideoDemo
streamUrl={
"https://fcc3ddae59ed.us-west-2.playback.live-video.net/api/video/v1/us-west-2.893648527354.channel.DmumNckWFTqz.m3u8"
}
debugToolsEnabled={false}
/>
);
}

export default App;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { HlsjsVidstack } from "./players/hlsjs/HlsjsVidstack";
import { PeerDetails } from "p2p-media-loader-core";

type DemoProps = {
streamUrl?: string;
debugToolsEnabled?: boolean;
};

Expand Down Expand Up @@ -53,7 +54,10 @@ const playerComponents = {
vidstack_hls: HlsjsVidstack,
};

export const P2PVideoDemo = ({ debugToolsEnabled = false }: DemoProps) => {
export const P2PVideoDemo = ({
streamUrl,
debugToolsEnabled = false,
}: DemoProps) => {
const data = useRef<DownloadStats>({
httpDownloaded: 0,
p2pDownloaded: 0,
Expand Down Expand Up @@ -115,7 +119,7 @@ export const P2PVideoDemo = ({ debugToolsEnabled = false }: DemoProps) => {

return PlayerComponent ? (
<PlayerComponent
streamUrl={queryParams.streamUrl}
streamUrl={streamUrl ?? queryParams.streamUrl}
announceTrackers={trackers}
onPeerConnect={onPeerConnect}
onPeerClose={onPeerClose}
Expand Down

0 comments on commit fb5300b

Please sign in to comment.