Skip to content

Commit

Permalink
Amend package:web tweaks to allow package:web roll (flutter#6793)
Browse files Browse the repository at this point in the history
dart-lang/web@7604578 adds a number of APIs in order to get a more consistent API surface. This includes disablePictureInPicture and disableRemotePlayback, which both take in a bool and not a JSBoolean. However, it can't be rolled into google3 as this package will now be broken due to the way extension type methods take a higher precedence over extension methods.

This CL aligns those methods with the package:web equivalent so that usages of these methods can be consistent. controlsList is also amended to take in a String so that if it's ever added to the Web IDL, it doesn't conflict with the package:web definition that will be added then.
  • Loading branch information
srujzs committed May 29, 2024
1 parent a5dd314 commit 910fabb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
6 changes: 5 additions & 1 deletion packages/video_player/video_player_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## 2.3.1

* Fixes some `package:web` tweaks.

## 2.3.0

* Migrates package and tests to `package:web``.
* Migrates package and tests to `package:web`.
* Fixes infinite event loop caused by `seekTo` when the video ends.

## 2.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ import 'package:web/web.dart' as web;
/// Adds a `controlsList` and `disablePictureInPicture` getters.
extension NonStandardGettersOnVideoElement on web.HTMLVideoElement {
external web.DOMTokenList? get controlsList;
external JSBoolean get disablePictureInPicture;
// TODO(srujzs): This will be added in `package:web` 0.6.0. Remove this helper
// once it's available.
external bool get disablePictureInPicture;
}

/// Adds a `disableRemotePlayback` getter.
extension NonStandardGettersOnMediaElement on web.HTMLMediaElement {
external JSBoolean get disableRemotePlayback;
// TODO(srujzs): This will be added in `package:web` 0.6.0. Remove this helper
// once it's available.
external bool get disableRemotePlayback;
}

/// Defines JS interop to access static methods from `Object`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:js_interop';
import 'package:web/web.dart' as web;

/// Adds a "disablePictureInPicture" setter to [web.HTMLVideoElement]s.
extension NonStandardSettersOnVideoElement on web.HTMLVideoElement {
external set disablePictureInPicture(JSBoolean disabled);
// TODO(srujzs): This will be added in `package:web` 0.6.0. Remove this helper
// once it's available.
external set disablePictureInPicture(bool disabled);
}

/// Adds a "disableRemotePlayback" and "controlsList" setters to [web.HTMLMediaElement]s.
extension NonStandardSettersOnMediaElement on web.HTMLMediaElement {
external set disableRemotePlayback(JSBoolean disabled);
external set controlsList(JSString? controlsList);
// TODO(srujzs): This will be added in `package:web` 0.6.0. Remove this helper
// once it's available.
external set disableRemotePlayback(bool disabled);
external set controlsList(String? controlsList);
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ class VideoPlayer {
_videoElement.controls = true;
final String controlsList = options.controls.controlsList;
if (controlsList.isNotEmpty) {
_videoElement.controlsList = controlsList.toJS;
_videoElement.controlsList = controlsList;
}

if (!options.controls.allowPictureInPicture) {
_videoElement.disablePictureInPicture = true.toJS;
_videoElement.disablePictureInPicture = true;
}
}

Expand All @@ -254,7 +254,7 @@ class VideoPlayer {
}

if (!options.allowRemotePlayback) {
_videoElement.disableRemotePlayback = true.toJS;
_videoElement.disableRemotePlayback = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/video_player_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: video_player_web
description: Web platform implementation of video_player.
repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
version: 2.3.0
version: 2.3.1

environment:
sdk: ^3.3.0
Expand Down

0 comments on commit 910fabb

Please sign in to comment.