WebSourcesMapper class
Pure-Dart mapper from a Dart ByteArkPlayerSource list to the JS
sources: [{ src, type, title, subtitle, videoId, poster, drm }, …]
array shape the ByteArk Web SDK expects.
Reorder rule (hotfix). When the ByteArk Web SDK is handed a multi-
DRM array, it does not key-system-filter — it walks the array in order
and picks the first source whose media MIME the browser can play.
Shaka can play HLS on Chromium, so a [FairPlay HLS, Widevine DASH]
list causes Chrome to pick the FairPlay source and fail decryption.
The mapper therefore performs a stable reorder that lifts Widevine
sources to the front. Safari still receives the FairPlay source it
needs (Safari falls through Widevine because there's no Widevine key
system on it), and Chromium/Edge/Firefox/Android-browsers see
Widevine at index 0.
Item metadata fan-out. The ByteArk Web SDK accepts title,
subtitle, videoId, and poster on each source object (per its
docs: title and videoId are required when Lighthouse is enabled).
The Dart side carries these on ByteArkPlayerItem; the mapper
spreads them onto every emitted source. Multi-source Items (e.g.
Multi-DRM FairPlay + Widevine) repeat the metadata across each
source because conceptually they're the same media.
MIME type is preserved as-is when the source provides one (the
non-DRM constructor leaves it null; the .drm() factory already
inferred HLS / DASH from the DRM scheme). Sources without type
omit the key entirely so the SDK can sniff.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
requiresShakaPlugin(
List< ByteArkPlayerSource> sources) → bool -
Whether the JS
plugins.bytearkShakaplugin needs to be enabled for the given sources. Returnstrueiff at least one source carries DRM credentials. -
toJsSources(
List< ByteArkPlayerSource> sources, {ByteArkPlayerItem? item}) → List<Map< String, dynamic> > -
Maps
sourcesto the JS sources array. Throws ArgumentError on an empty list (callers are expected to validate earlier).