Skip to content

Videos

Play a video in your app

Play Appwrite Videos streams on the web, Apple platforms, Android, Flutter, and React Native by loading the master manifest in a standard player.

4 min read

Raw

Appwrite Videos streams work with standard HLS and DASH players. You give the player the master manifest URL, and it handles adaptive bitrate and captions on its own. There is no Appwrite SDK to add for playback.

To put a video on a website without building a player, embed the video player with an iframe instead.

Install page with the Web platform, hls.js, Vanilla, and CMAF (HLS) selected, and the install steps and code
Install page with the Web platform, hls.js, Vanilla, and CMAF (HLS) selected, and the install steps and code

Before you start

  1. Make sure the video has at least one ready rendition for the output you want to play.
  2. Grant read access on the video to the viewers who should watch it. For a public video, turn on Public playback in the video's Settings. See Permissions.
  3. Copy the master manifest URL from the video's Streaming page, or build it as described in Outputs:
Plain text
https://<REGION>.cloud.appwrite.io/v1/videos/<VIDEO_ID>/outputs/cmaf/master.m3u8?project=<PROJECT_ID>

Use the .m3u8 manifest with HLS players and the .mpd manifest with DASH players.

In your app, build the URL from the video ID you store with your data, rather than hard-coding it:

JavaScript
const APPWRITE_ENDPOINT = 'https://<REGION>.cloud.appwrite.io/v1';
const PROJECT_ID = '<PROJECT_ID>';
function manifestUrl(videoId, format = 'm3u8') {
return `${APPWRITE_ENDPOINT}/videos/${videoId}/outputs/cmaf/master.${format}?project=${PROJECT_ID}`;
}

Choose a player

PlatformStart withWhy
Webhls.jsSmall, plays HLS everywhere, falls back to Safari's native player
Web, with DASH or more controlShaka Player or Video.jsPlays HLS and DASH, with richer APIs and plugins
iOS, iPadOS, tvOS, macOSAVPlayerBuilt into the OS, nothing to install
AndroidMedia3 ExoPlayerGoogle's recommended player, plays HLS and DASH
Fluttervideo_playerThe official Flutter plugin
React Nativereact-native-videoThe most widely used React Native player

Add a player

hls.js plays HLS in every modern browser. Safari plays HLS natively, so fall back to the <video> element there. If you only target Safari and iOS, a plain <video src="<HLS_MANIFEST_URL>"> is enough.

Bash
npm install hls.js
JavaScript
import Hls from 'hls.js'
const video = document.getElementById('player')
const src = '<HLS_MANIFEST_URL>'
if (Hls.isSupported()) {
const hls = new Hls()
hls.loadSource(src)
hls.attachMedia(video)
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
// Safari plays HLS natively
video.src = src
}
Markup
<video id="player" controls playsinline></video>
<script type="module" src="/main.js"></script>

Captions

Captions are listed in the master manifest, so players that support text tracks show them in their captions menu without extra setup. The default caption turns on automatically.

Poster and thumbnails

Videos does not set a poster image. To show a frame before viewers press play, set the <video> element's poster to your own image. For scrubbing thumbnails, load the timeline into your player's thumbnail track, or render them yourself.

Autoplay

Browsers block autoplay with sound. To start playback on load, for example in a background or preview clip, mute the video and keep playsinline so iOS does not open it fullscreen:

Markup
<video id="player" muted autoplay playsinline loop></video>

Attach the stream as usual. Leave autoplay off for videos people choose to watch, and let them press play.

Clean up

Players hold network connections and decoders. In single-page apps, release them when the view goes away: call hls.destroy() for hls.js, player.destroy() for Shaka Player, and player.dispose() for Video.js. On mobile, release ExoPlayer and pause AVPlayer when the screen closes, as the examples above do.

Troubleshooting

SymptomCheck
404 with video_not_found on the manifestThe video's read permissions, and whether the request carries the viewer's session. See Private playback
404 with video_rendition_not_found on the master manifestNo rendition for that output is ready yet. Wait for encoding, or create a rendition for that output
Plays in the Console but not in your appThe Console plays private videos for project members. Turn on Public playback, or see Private playback
DASH does not play in SafariSafari has no native DASH. Use the HLS manifest, or CMAF HLS
Stalls or low qualityOpen the inspector to see buffer, bitrate, and network timing

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.