{"record":{"id":"ddaa82c9aa97670a","repo":"bilibili/flv.js","slug":"nativeplayer-mediadatasource-type-doesn-t-supp","errorCode":null,"errorMessage":"NativePlayer(${mediaDataSource.type}) doesn't support multipart playback!","messagePattern":"NativePlayer\\((.+?)\\) doesn't support multipart playback!","errorType":"validation","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/player/native-player.js","lineNumber":41,"sourceCode":"\n// Player wrapper for browser's native player (HTMLVideoElement) without MediaSource src. \nclass NativePlayer {\n\n    constructor(mediaDataSource, config) {\n        this.TAG = 'NativePlayer';\n        this._type = 'NativePlayer';\n        this._emitter = new EventEmitter();\n\n        this._config = createDefaultConfig();\n        if (typeof config === 'object') {\n            Object.assign(this._config, config);\n        }\n\n        if (mediaDataSource.type.toLowerCase() === 'flv') {\n            throw new InvalidArgumentException('NativePlayer does\\'t support flv MediaDataSource input!');\n        }\n        if (mediaDataSource.hasOwnProperty('segments')) {\n            throw new InvalidArgumentException(`NativePlayer(${mediaDataSource.type}) doesn't support multipart playback!`);\n        }\n\n        this.e = {\n            onvLoadedMetadata: this._onvLoadedMetadata.bind(this)\n        };\n\n        this._pendingSeekTime = null;\n        this._statisticsReporter = null;\n\n        this._mediaDataSource = mediaDataSource;\n        this._mediaElement = null;\n    }\n\n    destroy() {\n        if (this._mediaElement) {\n            this.unload();\n            this.detachMediaElement();\n        }","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/bilibili/flv.js/blob/42343088f22619cf014a057b3878fe3d320016a6/src/player/native-player.js#L23-L59","documentation":"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.","triggerScenarios":"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:...}]}).","commonSituations":"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.","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"],"exampleFix":"// before\nflvjs.createPlayer({ type: 'mpegts', segments: [{ url: 'a.ts' }, { url: 'b.ts' }] });\n// throws: NativePlayer(mpegts) doesn't support multipart playback!\n\n// after\nflvjs.createPlayer({ type: 'mpegts', isLive: true, url: 'a.ts' });\n// or use the MSE player build that supports segments","handlingStrategy":"validation","validationCode":"function canUseNativePlayer(mediaDataSource) {\n  return mediaDataSource\n    && typeof mediaDataSource.type === 'string'\n    && mediaDataSource.type.toLowerCase() !== 'flv'\n    && !Object.prototype.hasOwnProperty.call(mediaDataSource, 'segments');\n}\n\nif (!canUseNativePlayer(dataSource)) {\n  throw new Error('segments not supported by NativePlayer; use MSE-based player or single url');\n}\nflvjs.createPlayer(dataSource);","typeGuard":"function isSingleSourceDataSource(ds) {\n  return typeof ds === 'object'\n    && ds !== null\n    && typeof ds.url === 'string'\n    && !('segments' in ds);\n}","tryCatchPattern":"try {\n  const player = flvjs.createPlayer(dataSource);\n} catch (e) {\n  if (e instanceof flvjs.CustomException || /multipart playback/.test(e.message)) {\n    // rebuild dataSource without segments or fall back to MSE player\n  } else {\n    throw e;\n  }\n}","preventionTips":["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"],"tags":["javascript","media","configuration","flv-js","player"],"backgroundTag":"unsupported-media-source-config","analyzedSha":"42343088f22619cf014a057b3878fe3d320016a6","analyzedAt":"2026-09-01T00:27:28.147Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}