Video.js Flash Fallback SWF
videojs-swf is a legacy package that provides a compiled Flash (SWF) video player, designed to serve as a fallback technology for Video.js versions 5.x and below. In its era, it enabled Video.js to maintain a unified API, allowing its skins, plugins, and other features to function across both HTML5 and Flash environments, crucial for broader browser compatibility before HTML5 video was universally robust. The package, currently at version 5.4.2 (last updated in 2018), is essentially a build tool for a `.swf` asset rather than a directly importable JavaScript module. It has not seen active development in many years, aligning with the general end-of-life for Adobe Flash Player itself. For Video.js 6.x and above, the Flash tech was moved to a separate `videojs-flash` repository, though both `videojs-swf` and `videojs-flash` are now largely obsolete due to browser Flash EOL.
Common errors
-
Error: Flash is not supported or not installed.
cause The web browser has deprecated, blocked, or completely removed support for Adobe Flash Player, or the plugin is not installed/enabled.fixModern browsers do not support Flash. This error is expected. Transition all video content to HTML5 video formats and players. No fix for enabling Flash in modern browsers exists. -
Failed to load resource: the server responded with a status of 404 (Not Found) - /path/to/video-js.swf
cause The `video-js.swf` file is not present at the specified path on the web server, or the path configured in Video.js options is incorrect.fixVerify that the compiled `video-js.swf` asset is deployed to the correct server path and that the `flash.swf` option in your Video.js initialization precisely matches this URL. -
TypeError: Cannot read properties of undefined (reading 'swf')
cause This typically occurs if Video.js is an unsupported version (e.g., v6.x or newer) for `videojs-swf`, or if the 'flash' tech is not properly registered/recognized by the Video.js instance.fixEnsure you are using Video.js version 5.x or below if you intend to use `videojs-swf`. For Video.js 6.x+, the relevant package was `videojs-flash` (though also now obsolete).
Warnings
- breaking Adobe Flash Player reached End-of-Life (EOL) on December 31, 2020. All major web browsers (Chrome, Firefox, Safari, Edge) have since removed or blocked Flash support. This package and its compiled SWF are effectively unusable in modern web environments.
- breaking This `videojs-swf` package is specifically for Video.js versions 5.x and below. It is incompatible with Video.js 6.x and newer, where the Flash tech was moved to a separate package (`videojs-flash`). Attempting to use this SWF with newer Video.js versions will lead to unexpected behavior or player failures.
- gotcha Building the SWF requires the Adobe Flex SDK and specific configuration within its `flex-config.xml` file (e.g., `target-player` 10.3 and `swf-version` 12). Incorrect SDK setup or configuration can lead to compilation errors or an improperly built SWF.
- gotcha Using Flash-based video playback, even if technically possible in niche environments, poses significant security risks due to Flash Player's EOL and lack of ongoing security updates. It is highly vulnerable to exploits.
Install
-
npm install videojs-swf -
yarn add videojs-swf -
pnpm add videojs-swf
Imports
- video-js.swf
(No direct JS import; asset is referenced via Video.js options)
- Flash Tech Configuration (Legacy)
import 'videojs-swf'
videojs('my-video', { techOrder: ['flash', 'html5'], flash: { swf: '/path/to/video-js.swf' } });
Quickstart
<!DOCTYPE html>
<html>
<head>
<title>Video.js Flash Fallback Example</title>
<link href="https://vjs.zencdn.net/5.10.8/video-js.css" rel="stylesheet">
<script src="https://vjs.zencdn.net/5.10.8/video.js"></script>
<style>
body { font-family: sans-serif; }
.video-container { width: 640px; margin: 20px auto; }
</style>
</head>
<body>
<div class="video-container">
<h1>Video.js with Flash Fallback (Legacy)</h1>
<p>This example demonstrates how to configure Video.js v5.x to use a compiled Flash SWF for playback.
<b>Note: Flash Player is no longer supported by modern browsers. This demo will likely fail to play video.</b></p>
<video id="my-video" class="video-js vjs-default-skin" controls preload="auto" width="640" height="360"
poster="https://vjs.zencdn.net/v/oceans.png" data-setup="{}">
<source src="https://vjs.zencdn.net/v/oceans.mp4" type="video/mp4">
<source src="https://vjs.zencdn.net/v/oceans.webm" type="video/webm">
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
</video>
</div>
<script>
// Simulate having a locally built video-js.swf file
// In a real scenario, you would compile videojs-swf and place the output `video-js.swf`
// in a path accessible by your web server.
const swfPath = '/path/to/your/compiled/video-js.swf'; // REPLACE WITH ACTUAL PATH
videojs('my-video', {
techOrder: ['flash', 'html5'], // Prioritize Flash if available
flash: {
swf: swfPath // Point to the compiled SWF asset
}
}, function() {
console.log('Video.js player is ready (v5.10.8)');
console.log('Flash SWF path configured:', swfPath);
// The player will attempt to load the Flash tech if HTML5 fails or is not preferred.
// In modern browsers, this will almost certainly fail due to Flash EOL.
});
</script>
</body>
</html>