🚧 The Shelby Explorer is currently in beta and is under active development

Shelby SymbolMedia Kit

Playing a Video

Stream video from Shelby


Introduction

Stream your uploaded video from Shelby's decentralized storage network using the Shelby Video Player. The player handles adaptive bitrate streaming, quality selection, and provides a full-featured playback experience.

Workflow diagram showing Get Blob Key, Construct URL, Setup Styles, and Render Player steps
Get Blob Key
Construct URL
Setup Styles
Render Player

Prerequisites

Before playing a video, make sure you have:

Step 1: Get Your Blob Key

When you uploaded your video, you received an account address and blob name. Retrieve these from your database or storage:

// From your database or upload response
const account = "7b1ada...3996";
const blobName = "video/playlist.m3u8";

Step 2: Construct the Playback URL

Combine the account and blob name with the Shelby storage API to create the playback URL:

Constructing the Playback URLBase URLhttps://api.shelbynet.shelby.xyz/v1/blobs/+Account7b1ada...3996/Blob Namevideo/playlist.m3u8=Playback URLhttps://api.shelbynet.shelby.xyz/v1/blobs/7b1ada...3996/video/playlist.m3u8
const playbackUrl = `https://api.shelbynet.shelby.xyz/v1/blobs/${account}/${blobName}`;

Step 3: Install the Player

Install the Shelby Video Player package:

npm install @shelby-protocol/player

Step 4: Setup Styles

The player requires TailwindCSS 4. Add the player styles to your globals.css:

globals.css
@import "tailwindcss";
@import "@shelby-protocol/player/styles/neutral.css";

Using shadcn/ui? Import @shelby-protocol/player/styles/shadcn.css instead to match your theme.

Step 5: Render the Player

Import and use the VideoPlayer component with your playback URL:

import { VideoPlayer } from "@shelby-protocol/player";

function MyPlayer({ account, blobName }) {
  const playbackUrl = `https://api.shelbynet.shelby.xyz/v1/blobs/${account}/${blobName}`;

  return (
    <VideoPlayer src={playbackUrl} poster="/thumbnail.jpg" title="My Video" />
  );
}

Configuring Shaka Player

The player is powered by Shaka Player for adaptive streaming. Pass Shaka configuration through the config prop to customize streaming behavior:

<VideoPlayer
  src={playbackUrl}
  title="My Video"
  config={{
    abr: {
      enabled: true,
      defaultBandwidthEstimate: 2_000_000, // 2 Mbps
    },
    streaming: {
      bufferingGoal: 30, // seconds
      rebufferingGoal: 2,
    },
  }}
/>

Common Configuration Options

OptionDescription
abr.enabledEnable/disable adaptive bitrate
abr.defaultBandwidthEstimateInitial bandwidth estimate (bps)
streaming.bufferingGoalSeconds of content to buffer ahead
streaming.rebufferingGoalSeconds to buffer when rebuffering

For the full list of configuration options, see the Shaka Player Configuration documentation.

Accessing Shaka Player Directly

For advanced use cases, use the useShaka hook to access the Shaka Player API:

import { useShaka } from "@shelby-protocol/player";

function CustomControls() {
  const player = useShaka();

  const tracks = player?.getVariantTracks() ?? [];
  const currentTrack = tracks.find((track) => track.active);

  return <div>Current quality: {currentTrack?.height}p</div>;
}

Next Steps


On this page