Media constructor

Media(
  1. String resource, {
  2. Map<String, dynamic>? extras,
  3. Map<String, String>? httpHeaders,
})

Media

A Media object to open inside a Player for playback.

final player = Player();
final playable = Media('https://user-images.githubusercontent.com/28951144/229373695-22f88f13-d18f-4288-9bf1-c3e078d83722.mp4');
await player.open(playable);

Implementation

Media(
  String resource, {
  Map<String, dynamic>? extras,
  Map<String, String>? httpHeaders,
})  : uri = normalizeURI(resource),
      extras = extras ?? cache[normalizeURI(resource)]?.extras,
      httpHeaders =
          httpHeaders ?? cache[normalizeURI(resource)]?.httpHeaders {
  // Increment reference count.
  ref[uri] = ((ref[uri] ?? 0) + 1).clamp(0, 1 << 32);
  // Store [this] instance in [cache].
  cache[uri] = _MediaCache(
    extras: this.extras,
    httpHeaders: this.httpHeaders,
  );
  // Attach [this] instance to [Finalizer].
  _finalizer.attach(this, uri);
}