Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaowei-guan committed Sep 9, 2024
2 parents a7d0abd + a4710b9 commit 6ec3fee
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 45 deletions.
8 changes: 6 additions & 2 deletions packages/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## NEXT
## 2.5.0

* Update video_player to 2.9.1.
* Update video_player_platform_interface to 6.2.0.
* Update the example app and integration_test.
* Fix new lint warnings.
* Update minimum Flutter and Dart version to 3.13 and 3.1.
* Update minimum Flutter and Dart version to 3.19 and 3.3.
* Synchronize VideoPlayerValue.isPlaying with underlying video player.

## 2.4.9

Expand Down
6 changes: 3 additions & 3 deletions packages/video_player/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ This package is not an _endorsed_ implementation of `video_player`. Therefore, y

```yaml
dependencies:
video_player: ^2.4.2
video_player_tizen: ^2.4.9
video_player: ^2.9.1
video_player_tizen: ^2.5.0
```
Then you can import `video_player` in your Dart code:
Expand Down Expand Up @@ -50,7 +50,7 @@ This plugin is not supported on TV emulators.

The following options are not supported on Tizen.

- The `httpHeaders` option of `VideoPlayerController.network`
- The `httpHeaders` option of `VideoPlayerController.networkUrl`
- `VideoPlayerOptions.allowBackgroundPlayback`
- `VideoPlayerOptions.mixWithOthers`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const String _videoAssetKey =
// TODO(stuartmorgan): Convert this to a local `HttpServer` that vends the
// assets directly, https://github.com/flutter/flutter/issues/95420
String getUrlForAssetAsNetworkSource(String assetKey) {
return 'https://github.com/flutter/plugins/blob/'
return 'https://github.com/flutter/packages/blob/'
// This hash can be rolled forward to pick up newly-added assets.
'cb381ced070d356799dddf24aca38ce0579d3d7b'
'2e1673307ff7454aff40b47024eaed49a9e77e81'
'/packages/video_player/video_player/example/'
'$assetKey'
'?raw=true';
Expand Down Expand Up @@ -57,8 +57,9 @@ void main() {
'live stream duration != 0',
(WidgetTester tester) async {
final VideoPlayerController networkController =
VideoPlayerController.network(
'https://flutter.github.io/assets-for-api-docs/assets/videos/hls/bee.m3u8',
VideoPlayerController.networkUrl(
Uri.parse(
'https://flutter.github.io/assets-for-api-docs/assets/videos/hls/bee.m3u8'),
);
await networkController.initialize();

Expand Down Expand Up @@ -127,20 +128,36 @@ void main() {
// Mute to allow playing without DOM interaction on Web.
// See https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
await controller.setVolume(0);
final Duration timeBeforeEnd =
controller.value.duration - const Duration(milliseconds: 500);
await controller.seekTo(timeBeforeEnd);
final Duration tenMillisBeforeEnd =
controller.value.duration - const Duration(milliseconds: 10);
await controller.seekTo(tenMillisBeforeEnd);
await controller.play();
await tester.pumpAndSettle(_playDuration);
// Android emulators in our CI have frequent flake where the video
// reports as still playing (usually without having advanced at all
// past the seek position, but sometimes having advanced some); if that
// happens, the thing being tested hasn't even had a chance to happen
// due to CI issues, so just report it as skipped.
// TODO(stuartmorgan): Remove once
// https://github.com/flutter/flutter/issues/141145 is fixed.
if ((!kIsWeb && Platform.isAndroid) && controller.value.isPlaying) {
markTestSkipped(
'Skipping due to https://github.com/flutter/flutter/issues/141145');
return;
}
expect(controller.value.isPlaying, false);
expect(controller.value.position, controller.value.duration);

await controller.seekTo(timeBeforeEnd);
await controller.seekTo(tenMillisBeforeEnd);
await tester.pumpAndSettle(_playDuration);

expect(controller.value.isPlaying, false);
expect(controller.value.position, timeBeforeEnd);
expect(controller.value.position, tenMillisBeforeEnd);
},
// Flaky on web: https://github.com/flutter/flutter/issues/130147
//skip: kIsWeb,
// NOTE(jsuya): In Tizen, isPlaying returns true after the play() call.
skip: true,
);

testWidgets(
Expand All @@ -151,9 +168,24 @@ void main() {
// See https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
await controller.setVolume(0);
await controller.seekTo(
controller.value.duration - const Duration(milliseconds: 500));
controller.value.duration - const Duration(milliseconds: 10));
await controller.play();
await tester.pumpAndSettle(_playDuration);
// Android emulators in our CI have frequent flake where the video
// reports as still playing (usually without having advanced at all
// past the seek position, but sometimes having advanced some); if that
// happens, the thing being tested hasn't even had a chance to happen
// due to CI issues, so just report it as skipped.
// TODO(stuartmorgan): Remove once
// https://github.com/flutter/flutter/issues/141145 is fixed.

// NOTE(jsuya): In Tizen, isPlaying returns true after the play()
// call,so subsequent tests cannot be performed.
if ((!kIsWeb && Platform.isAndroid) && controller.value.isPlaying) {
markTestSkipped(
'Skipping due to https://github.com/flutter/flutter/issues/141145');
return;
}
expect(controller.value.isPlaying, false);
expect(controller.value.position, controller.value.duration);

Expand All @@ -163,13 +195,17 @@ void main() {
expect(controller.value.position,
lessThanOrEqualTo(controller.value.duration));
},
// NOTE(jsuya): In Tizen, isPlaying returns true after the play() call.
skip: true,
);

testWidgets('test video player view with local asset',
(WidgetTester tester) async {
final Completer<void> loaded = Completer<void>();
Future<bool> started() async {
await controller.initialize();
await controller.play();
loaded.complete();
return true;
}

Expand All @@ -194,12 +230,12 @@ void main() {
),
));

await loaded.future;
await tester.pumpAndSettle();
expect(controller.value.isPlaying, true);
},
skip: kIsWeb || // Web does not support local assets.
// Extremely flaky on iOS: https://github.com/flutter/flutter/issues/86915
defaultTargetPlatform == TargetPlatform.iOS);
// Web does not support local assets.
skip: kIsWeb);
});

group('file-based videos', () {
Expand Down Expand Up @@ -230,8 +266,8 @@ void main() {

group('network videos', () {
setUp(() {
controller = VideoPlayerController.network(
getUrlForAssetAsNetworkSource(_videoAssetKey));
controller = VideoPlayerController.networkUrl(
Uri.parse(getUrlForAssetAsNetworkSource(_videoAssetKey)));
});

testWidgets(
Expand Down Expand Up @@ -283,7 +319,7 @@ void main() {
expect(controller.value.isInitialized, true);
expect(controller.value.position, Duration.zero);
expect(controller.value.isPlaying, false);
// Due to the duration calculation accurancy between platforms,
// Due to the duration calculation accuracy between platforms,
// the milliseconds on Web will be a slightly different from natives.
// The audio was made with 44100 Hz, 192 Kbps CBR, and 32 bits.
expect(
Expand Down
40 changes: 23 additions & 17 deletions packages/video_player/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,26 @@ class _ExampleCard extends StatelessWidget {
leading: const Icon(Icons.airline_seat_flat_angled),
title: Text(title),
),
ButtonBar(
children: <Widget>[
TextButton(
child: const Text('BUY TICKETS'),
onPressed: () {
/* ... */
},
),
TextButton(
child: const Text('SELL TICKETS'),
onPressed: () {
/* ... */
},
),
],
Padding(
padding: const EdgeInsets.all(8.0),
child: OverflowBar(
alignment: MainAxisAlignment.end,
spacing: 8.0,
children: <Widget>[
TextButton(
child: const Text('BUY TICKETS'),
onPressed: () {
/* ... */
},
),
TextButton(
child: const Text('SELL TICKETS'),
onPressed: () {
/* ... */
},
),
],
),
),
],
),
Expand Down Expand Up @@ -218,8 +223,9 @@ class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> {
@override
void initState() {
super.initState();
_controller = VideoPlayerController.network(
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4',
_controller = VideoPlayerController.networkUrl(
Uri.parse(
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4'),
closedCaptionFile: _loadCaptions(),
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
);
Expand Down
6 changes: 3 additions & 3 deletions packages/video_player/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ description: Demonstrates how to use the video_player_tizen plugin.
publish_to: "none"

environment:
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
sdk: ">=3.3.0 <4.0.0"
flutter: ">=3.19.0"

dependencies:
flutter:
sdk: flutter
video_player: ^2.4.2
video_player: ^2.9.1
video_player_tizen:
path: ../

Expand Down
5 changes: 5 additions & 0 deletions packages/video_player/lib/video_player_tizen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ class VideoPlayerTizen extends VideoPlayerPlatform {
return VideoEvent(eventType: VideoEventType.bufferingStart);
case 'bufferingEnd':
return VideoEvent(eventType: VideoEventType.bufferingEnd);
case 'isPlayingStateUpdate':
return VideoEvent(
eventType: VideoEventType.isPlayingStateUpdate,
isPlaying: map['isPlaying'] as bool,
);
default:
return VideoEvent(eventType: VideoEventType.unknown);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: video_player_tizen
description: Tizen implementation of the video_player plugin.
homepage: https://github.com/flutter-tizen/plugins
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/video_player
version: 2.4.9
version: 2.5.0

environment:
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"
sdk: ">=3.3.0 <4.0.0"
flutter: ">=3.19.0"

flutter:
plugin:
Expand All @@ -19,7 +19,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
video_player_platform_interface: ^5.1.2
video_player_platform_interface: ^6.2.0

dev_dependencies:
pigeon: ^10.0.0
14 changes: 14 additions & 0 deletions packages/video_player/tizen/src/video_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ void VideoPlayer::Play() {
#ifdef TV_PROFILE
timer_ = ecore_timer_add(30, ResetScreensaverTimeout, this);
#endif

SendIsPlayingStateUpdate(true);
}

void VideoPlayer::Pause() {
Expand All @@ -294,6 +296,8 @@ void VideoPlayer::Pause() {
ecore_timer_del(timer_);
timer_ = nullptr;
}

SendIsPlayingStateUpdate(false);
}

void VideoPlayer::SetLooping(bool is_looping) {
Expand Down Expand Up @@ -474,6 +478,16 @@ void VideoPlayer::SendInitialized() {
}
}

void VideoPlayer::SendIsPlayingStateUpdate(bool is_playing) {
flutter::EncodableMap result = {
{flutter::EncodableValue("event"),
flutter::EncodableValue("isPlayingStateUpdate")},
{flutter::EncodableValue("isPlaying"),
flutter::EncodableValue(is_playing)},
};
PushEvent(flutter::EncodableValue(result));
}

Eina_Bool VideoPlayer::ResetScreensaverTimeout(void *data) {
LOG_DEBUG("[VideoPlayer] Reset screen saver timeout.");

Expand Down
1 change: 1 addition & 0 deletions packages/video_player/tizen/src/video_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class VideoPlayer {
void SetUpEventChannel(flutter::BinaryMessenger *messenger);
void Initialize();
void SendInitialized();
void SendIsPlayingStateUpdate(bool is_playing);
void InitScreenSaverApi();

static void OnPrepared(void *data);
Expand Down

0 comments on commit 6ec3fee

Please sign in to comment.