diff --git a/packages/video_player/video_player/CHANGELOG.md b/packages/video_player/video_player/CHANGELOG.md index 1c7da480c27c..ef35127b5823 100644 --- a/packages/video_player/video_player/CHANGELOG.md +++ b/packages/video_player/video_player/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.4.9 + +* Fixes file URI construction. + ## 2.4.8 * Updates code for new analysis options. diff --git a/packages/video_player/video_player/lib/video_player.dart b/packages/video_player/video_player/lib/video_player.dart index 2f84b826fd25..76f865aa7359 100644 --- a/packages/video_player/video_player/lib/video_player.dart +++ b/packages/video_player/video_player/lib/video_player.dart @@ -245,12 +245,11 @@ class VideoPlayerController extends ValueNotifier { /// Constructs a [VideoPlayerController] playing a video from a file. /// - /// This will load the file from the file-URI given by: - /// `'file://${file.path}'`. + /// This will load the file from a file:// URI constructed from [file]'s path. VideoPlayerController.file(File file, {Future? closedCaptionFile, this.videoPlayerOptions}) : _closedCaptionFileFuture = closedCaptionFile, - dataSource = 'file://${file.path}', + dataSource = Uri.file(file.absolute.path).toString(), dataSourceType = DataSourceType.file, package = null, formatHint = null, diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index 1f5fed29c01f..ace50f9890eb 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for displaying inline video with other Flutter widgets on Android, iOS, and web. repository: https://github.com/flutter/plugins/tree/main/packages/video_player/video_player issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 -version: 2.4.8 +version: 2.4.9 environment: sdk: ">=2.14.0 <3.0.0" diff --git a/packages/video_player/video_player/test/video_player_test.dart b/packages/video_player/video_player/test/video_player_test.dart index 973fab42bb02..a35264f21982 100644 --- a/packages/video_player/video_player/test/video_player_test.dart +++ b/packages/video_player/video_player/test/video_player_test.dart @@ -7,6 +7,7 @@ import 'dart:io'; import 'dart:math' as math; import 'dart:typed_data'; +import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -341,8 +342,21 @@ void main() { VideoPlayerController.file(File('a.avi')); await controller.initialize(); - expect(fakeVideoPlayerPlatform.dataSources[0].uri, 'file://a.avi'); - }); + final String uri = fakeVideoPlayerPlatform.dataSources[0].uri!; + expect(uri.startsWith('file:///'), true, reason: 'Actual string: $uri'); + expect(uri.endsWith('/a.avi'), true, reason: 'Actual string: $uri'); + }, skip: kIsWeb /* Web does not support file assets. */); + + test('file with special characters', () async { + final VideoPlayerController controller = + VideoPlayerController.file(File('A #1 Hit?.avi')); + await controller.initialize(); + + final String uri = fakeVideoPlayerPlatform.dataSources[0].uri!; + expect(uri.startsWith('file:///'), true, reason: 'Actual string: $uri'); + expect(uri.endsWith('/A%20%231%20Hit%3F.avi'), true, + reason: 'Actual string: $uri'); + }, skip: kIsWeb /* Web does not support file assets. */); test('successful initialize on controller with error clears error', () async { @@ -1009,16 +1023,16 @@ void main() { }); test('setMixWithOthers', () async { - final VideoPlayerController controller = VideoPlayerController.file( - File(''), + final VideoPlayerController controller = VideoPlayerController.network( + 'https://127.0.0.1', videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true)); await controller.initialize(); expect(controller.videoPlayerOptions!.mixWithOthers, true); }); test('true allowBackgroundPlayback continues playback', () async { - final VideoPlayerController controller = VideoPlayerController.file( - File(''), + final VideoPlayerController controller = VideoPlayerController.network( + 'https://127.0.0.1', videoPlayerOptions: VideoPlayerOptions( allowBackgroundPlayback: true, ), @@ -1032,8 +1046,8 @@ void main() { }); test('false allowBackgroundPlayback pauses playback', () async { - final VideoPlayerController controller = VideoPlayerController.file( - File(''), + final VideoPlayerController controller = VideoPlayerController.network( + 'https://127.0.0.1', videoPlayerOptions: VideoPlayerOptions(), ); await controller.initialize(); diff --git a/packages/video_player/video_player_android/CHANGELOG.md b/packages/video_player/video_player_android/CHANGELOG.md index 7137e244bc43..bad1fb427733 100644 --- a/packages/video_player/video_player_android/CHANGELOG.md +++ b/packages/video_player/video_player_android/CHANGELOG.md @@ -1,5 +1,6 @@ ## NEXT +* Fixes file URI construction in example. * Updates code for new analysis options. * Updates code for `no_leading_underscores_for_local_identifiers` lint. * Updates minimum Flutter version to 2.10. diff --git a/packages/video_player/video_player_android/example/lib/mini_controller.dart b/packages/video_player/video_player_android/example/lib/mini_controller.dart index 26c60b72a4d4..fb79a77fb2cb 100644 --- a/packages/video_player/video_player_android/example/lib/mini_controller.dart +++ b/packages/video_player/video_player_android/example/lib/mini_controller.dart @@ -150,7 +150,7 @@ class MiniController extends ValueNotifier { /// Constructs a [MiniController] playing a video from obtained from a file. MiniController.file(File file) - : dataSource = 'file://${file.path}', + : dataSource = Uri.file(file.absolute.path).toString(), dataSourceType = DataSourceType.file, package = null, super(VideoPlayerValue(duration: Duration.zero)); diff --git a/packages/video_player/video_player_avfoundation/CHANGELOG.md b/packages/video_player/video_player_avfoundation/CHANGELOG.md index 1198599dfc93..d18437235db4 100644 --- a/packages/video_player/video_player_avfoundation/CHANGELOG.md +++ b/packages/video_player/video_player_avfoundation/CHANGELOG.md @@ -1,5 +1,6 @@ ## NEXT +* Fixes file URI construction in example. * Updates code for new analysis options. * Adds an integration test for a bug where the aspect ratios of some HLS videos are incorrectly inverted. * Removes an unnecessary override in example code. @@ -11,7 +12,7 @@ ## 2.3.6 -* Fixes a bug in iOS 16 where videos from protected live streams are not shown. +* Fixes a bug in iOS 16 where videos from protected live streams are not shown. * Updates minimum Flutter version to 2.10. * Fixes violations of new analysis option use_named_constants. * Fixes avoid_redundant_argument_values lint warnings and minor typos. diff --git a/packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart b/packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart index 26c60b72a4d4..fb79a77fb2cb 100644 --- a/packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart +++ b/packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart @@ -150,7 +150,7 @@ class MiniController extends ValueNotifier { /// Constructs a [MiniController] playing a video from obtained from a file. MiniController.file(File file) - : dataSource = 'file://${file.path}', + : dataSource = Uri.file(file.absolute.path).toString(), dataSourceType = DataSourceType.file, package = null, super(VideoPlayerValue(duration: Duration.zero)); diff --git a/packages/video_player/video_player_platform_interface/CHANGELOG.md b/packages/video_player/video_player_platform_interface/CHANGELOG.md index 05cb63835da4..fb7a3b340ca9 100644 --- a/packages/video_player/video_player_platform_interface/CHANGELOG.md +++ b/packages/video_player/video_player_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.0.1 + +* Fixes comment describing file URI construction. + ## 6.0.0 * **BREAKING CHANGE**: Removes `MethodChannelVideoPlayer`. The default diff --git a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart index 92099eb6635a..d3df9b25df53 100644 --- a/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart +++ b/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart @@ -114,7 +114,7 @@ class DataSource { /// The [sourceType] is always required. /// /// The [uri] argument takes the form of `'https://example.com/video.mp4'` or - /// `'file://${file.path}'`. + /// `'file:///absolute/path/to/local/video.mp4`. /// /// The [formatHint] argument can be null. /// diff --git a/packages/video_player/video_player_platform_interface/pubspec.yaml b/packages/video_player/video_player_platform_interface/pubspec.yaml index 56e132dbb3a7..36c0a7181845 100644 --- a/packages/video_player/video_player_platform_interface/pubspec.yaml +++ b/packages/video_player/video_player_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/main/packages/video_player/v issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 6.0.0 +version: 6.0.1 environment: sdk: ">=2.12.0 <3.0.0"