Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/video_player/video_player_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.3.5

* Fixes blank first frame on iOS.

## 2.3.4

* Adjusts the code to the new platform interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// found in the LICENSE file.

import 'dart:async';
import 'dart:js_interop';
import 'dart:js_interop_unsafe';

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
Expand All @@ -27,6 +29,18 @@ void main() {
..playsInline = false;
});

testWidgets('initialize() calls load', (WidgetTester _) async {
bool loadCalled = false;

video['load'] = () {
Comment thread
ditman marked this conversation as resolved.
loadCalled = true;
}.toJS;

VideoPlayer(videoElement: video).initialize();

expect(loadCalled, isTrue);
});

testWidgets('fixes critical video element config', (WidgetTester _) async {
VideoPlayer(videoElement: video).initialize();

Expand Down Expand Up @@ -130,6 +144,11 @@ void main() {
);
});

tearDown(() {
streamController.close();
player.dispose();
});

testWidgets('buffering dispatches only when it changes',
(WidgetTester tester) async {
// Take all the "buffering" events that we see during the next few seconds
Expand Down Expand Up @@ -222,8 +241,7 @@ void main() {
expect(events[0].eventType, VideoEventType.initialized);
});

// Issue: https://github.com/flutter/flutter/issues/137023
Comment thread
ditman marked this conversation as resolved.
testWidgets('loadedmetadata dispatches initialized',
testWidgets('loadedmetadata does not dispatch initialized',
(WidgetTester tester) async {
video.dispatchEvent(web.Event('loadedmetadata'));
video.dispatchEvent(web.Event('loadedmetadata'));
Expand All @@ -235,8 +253,22 @@ void main() {

final List<VideoEvent> events = await stream;

expect(events, hasLength(1));
expect(events[0].eventType, VideoEventType.initialized);
expect(events, isEmpty);
});

testWidgets('loadeddata does not dispatch initialized',
(WidgetTester tester) async {
video.dispatchEvent(web.Event('loadeddata'));
video.dispatchEvent(web.Event('loadeddata'));

final Future<List<VideoEvent>> stream = timedStream
.where((VideoEvent event) =>
event.eventType == VideoEventType.initialized)
.toList();

final List<VideoEvent> events = await stream;

expect(events, isEmpty);
});

// Issue: https://github.com/flutter/flutter/issues/105649
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ class VideoPlayer {
..playsInline = true;

_videoElement.onCanPlay.listen(_onVideoElementInitialization);
// Needed for Safari iOS 17, which may not send `canplay`.
_videoElement.onLoadedMetadata.listen(_onVideoElementInitialization);

_videoElement.onCanPlayThrough.listen((dynamic _) {
setBuffering(false);
Expand Down Expand Up @@ -131,6 +129,10 @@ class VideoPlayer {
if (src != null) {
_videoElement.src = src;
}

// Explicitly triggers media loading in preparation for playback. Needed on
// iOS to ensure the first frame becomes visible before playback begins.
_videoElement.load();
Comment thread
ditman marked this conversation as resolved.
}

/// Attempts to play the video.
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.4
version: 2.3.5

environment:
sdk: ^3.4.0
Expand Down