forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[video_player_web] migrates to package:web (flutter#5800)
Updates the web implementation of `video_player_web` to `package:web`. Also: prevents an infinite event loop when seeking to the end of a video after it's done. ### Issues * Fixes: flutter#139752 Co-authored-by: ToddZeil <120418414+ToddZeil@users.noreply.github.com>
- Loading branch information
1 parent
79faa24
commit b097d99
Showing
9 changed files
with
224 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
packages/video_player/video_player_web/example/integration_test/pkg_web_tweaks.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
@JS() | ||
library video_player_web_integration_test_pkg_web_tweaks; | ||
|
||
import 'dart:js_interop'; | ||
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; | ||
} | ||
|
||
/// Adds a `disableRemotePlayback` getter. | ||
extension NonStandardGettersOnMediaElement on web.HTMLMediaElement { | ||
external JSBoolean get disableRemotePlayback; | ||
} | ||
|
||
/// Defines JS interop to access static methods from `Object`. | ||
@JS('Object') | ||
extension type DomObject._(JSAny _) { | ||
@JS('defineProperty') | ||
external static void _defineProperty( | ||
JSAny? object, JSString property, Descriptor value); | ||
|
||
/// `Object.defineProperty`. | ||
/// | ||
/// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty | ||
static void defineProperty( | ||
JSObject object, String property, Descriptor descriptor) { | ||
return _defineProperty(object, property.toJS, descriptor); | ||
} | ||
} | ||
|
||
/// The descriptor for the property being defined or modified with `defineProperty`. | ||
/// | ||
/// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#description | ||
extension type Descriptor._(JSObject _) implements JSObject { | ||
/// Builds a "data descriptor". | ||
factory Descriptor.data({ | ||
bool? writable, | ||
JSAny? value, | ||
}) => | ||
Descriptor._data( | ||
writable: writable?.toJS, | ||
value: value.jsify(), | ||
); | ||
|
||
/// Builds an "accessor descriptor". | ||
factory Descriptor.accessor({ | ||
void Function(JSAny? value)? set, | ||
JSAny? Function()? get, | ||
}) => | ||
Descriptor._accessor( | ||
set: set?.toJS, | ||
get: get?.toJS, | ||
); | ||
|
||
external factory Descriptor._accessor({ | ||
// JSBoolean configurable, | ||
// JSBoolean enumerable, | ||
JSFunction? set, | ||
JSFunction? get, | ||
}); | ||
|
||
external factory Descriptor._data({ | ||
// JSBoolean configurable, | ||
// JSBoolean enumerable, | ||
JSBoolean? writable, | ||
JSAny? value, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.