bilibili/flv.js · error · InvalidArgumentException
NativePlayer(${mediaDataSource.type}) doesn't support multip
Error message
NativePlayer(${mediaDataSource.type}) doesn't support multipart playback! What it means
NativePlayer only plays a single, directly playable media URL by setting it on the underlying HTMLMediaElement's src. It has no support for the 'segments' array (multipart playback) that MPEG-DASH-style MediaDataSources can carry; only MPEGTS/FLV via MSE players (flv.js/MPEGTS player) supports segments. Passing a MediaDataSource with a 'segments' property is rejected immediately in the constructor with InvalidArgumentException.
Source
Thrown at src/player/native-player.js:41
// Player wrapper for browser's native player (HTMLVideoElement) without MediaSource src.
class NativePlayer {
constructor(mediaDataSource, config) {
this.TAG = 'NativePlayer';
this._type = 'NativePlayer';
this._emitter = new EventEmitter();
this._config = createDefaultConfig();
if (typeof config === 'object') {
Object.assign(this._config, config);
}
if (mediaDataSource.type.toLowerCase() === 'flv') {
throw new InvalidArgumentException('NativePlayer does\'t support flv MediaDataSource input!');
}
if (mediaDataSource.hasOwnProperty('segments')) {
throw new InvalidArgumentException(`NativePlayer(${mediaDataSource.type}) doesn't support multipart playback!`);
}
this.e = {
onvLoadedMetadata: this._onvLoadedMetadata.bind(this)
};
this._pendingSeekTime = null;
this._statisticsReporter = null;
this._mediaDataSource = mediaDataSource;
this._mediaElement = null;
}
destroy() {
if (this._mediaElement) {
this.unload();
this.detachMediaElement();
}View on GitHub (pinned to 42343088f2)
Solutions
- Remove the 'segments' property from the mediaDataSource and play a single 'url' instead
- Use the MSE-based player (flv.js / mpegts.js createPlayer with type 'mpegts' or 'flv') which supports multipart playback
- If segments are alternative sources, pick one URL manually and pass it in 'url'
- Check mediaDataSource.hasOwnProperty('segments') before creating NativePlayer and route to the appropriate player
Example fix
// before
flvjs.createPlayer({ type: 'mpegts', segments: [{ url: 'a.ts' }, { url: 'b.ts' }] });
// throws: NativePlayer(mpegts) doesn't support multipart playback!
// after
flvjs.createPlayer({ type: 'mpegts', isLive: true, url: 'a.ts' });
// or use the MSE player build that supports segments Defensive patterns
Strategy: validation
Validate before calling
function canUseNativePlayer(mediaDataSource) {
return mediaDataSource
&& typeof mediaDataSource.type === 'string'
&& mediaDataSource.type.toLowerCase() !== 'flv'
&& !Object.prototype.hasOwnProperty.call(mediaDataSource, 'segments');
}
if (!canUseNativePlayer(dataSource)) {
throw new Error('segments not supported by NativePlayer; use MSE-based player or single url');
}
flvjs.createPlayer(dataSource); Type guard
function isSingleSourceDataSource(ds) {
return typeof ds === 'object'
&& ds !== null
&& typeof ds.url === 'string'
&& !('segments' in ds);
} Try / catch
try {
const player = flvjs.createPlayer(dataSource);
} catch (e) {
if (e instanceof flvjs.CustomException || /multipart playback/.test(e.message)) {
// rebuild dataSource without segments or fall back to MSE player
} else {
throw e;
}
} Prevention
- Never include a 'segments' key in a MediaDataSource fed to NativePlayer
- Use createPlayer() and let the factory choose the player based on type/segments
- Validate mediaDataSource shape with a helper before constructing any player
- Keep single-URL and multi-segment configs in separate code paths
When it happens
Trigger: Constructing NativePlayer directly, or being auto-routed to it via createPlayer(), with a mediaDataSource object that has a 'segments' property (e.g. {type:'mpegts', segments:[{url:...},{url:...}]}).
Common situations: Developers reuse a DASH-like multi-segment config intended for the MSE-based player; they upgrade a single-URL config to multi-part streams without switching player factory behavior; they leave a stale 'segments' key from copy-pasted config even with an empty array.
Related errors
- HTMLMediaElement must be attached before load()!
- MediaDataSource must be an javascript object!
- MediaDataSource must has type field to indicate video file t
- FlvPlayer requires an flv MediaDataSource input!
- HTMLMediaElement must be attached before load()!
AI-assisted analysis of bilibili/flv.js@42343088f2 (2026-09-01).
Data as JSON: /api/errors/ddaa82c9aa97670a.
Report an issue: GitHub.