From cf011a517c0576d520b4d7b05e0bc22c7da85392 Mon Sep 17 00:00:00 2001 From: Zaldy Jr Pagaduan Date: Tue, 27 Jun 2023 07:39:57 +0800 Subject: [PATCH 1/7] added iOS exception on incorrect asset path --- .../video_player_avfoundation/CHANGELOG.md | 3 ++- .../ios/Classes/FLTVideoPlayerPlugin.m | 14 ++++++++++---- .../video_player_avfoundation/pubspec.yaml | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/video_player/video_player_avfoundation/CHANGELOG.md b/packages/video_player/video_player_avfoundation/CHANGELOG.md index a54aef55877..dcb5febc4da 100644 --- a/packages/video_player/video_player_avfoundation/CHANGELOG.md +++ b/packages/video_player/video_player_avfoundation/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 2.4.7 * Updates minimum supported SDK version to Flutter 3.3/Dart 2.18. +* Added iOS exception on incorrect asset path ## 2.4.6 diff --git a/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m b/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m index ccece112769..c9966d94427 100644 --- a/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m +++ b/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m @@ -620,10 +620,16 @@ - (FLTTextureMessage *)create:(FLTCreateMessage *)input error:(FlutterError **)e } else { assetPath = [_registrar lookupKeyForAsset:input.asset]; } - player = [[FLTVideoPlayer alloc] initWithAsset:assetPath - frameUpdater:frameUpdater - playerFactory:_playerFactory]; - return [self onPlayerSetup:player frameUpdater:frameUpdater]; + @try { + player = [[FLTVideoPlayer alloc] initWithAsset:assetPath + frameUpdater:frameUpdater + playerFactory:_playerFactory]; + return [self onPlayerSetup:player frameUpdater:frameUpdater]; + } + @catch (NSException *exception) { + *error = [FlutterError errorWithCode:@"video_player" message:exception.reason details:nil]; + return nil; + } } else if (input.uri) { player = [[FLTVideoPlayer alloc] initWithURL:[NSURL URLWithString:input.uri] frameUpdater:frameUpdater diff --git a/packages/video_player/video_player_avfoundation/pubspec.yaml b/packages/video_player/video_player_avfoundation/pubspec.yaml index 093f5ebbb51..a0c2f4ebae8 100644 --- a/packages/video_player/video_player_avfoundation/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/pubspec.yaml @@ -2,7 +2,7 @@ name: video_player_avfoundation description: iOS implementation of the video_player plugin. repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_avfoundation issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 -version: 2.4.6 +version: 2.4.7 environment: sdk: ">=2.18.0 <4.0.0" From 655208809843bf940b1d0448b4860e62eb358e39 Mon Sep 17 00:00:00 2001 From: Zaldy Jr Pagaduan Date: Wed, 28 Jun 2023 21:44:13 +0800 Subject: [PATCH 2/7] updated changelog --- packages/video_player/video_player_avfoundation/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/video_player/video_player_avfoundation/CHANGELOG.md b/packages/video_player/video_player_avfoundation/CHANGELOG.md index dcb5febc4da..e8642b6e04a 100644 --- a/packages/video_player/video_player_avfoundation/CHANGELOG.md +++ b/packages/video_player/video_player_avfoundation/CHANGELOG.md @@ -1,7 +1,7 @@ ## 2.4.7 * Updates minimum supported SDK version to Flutter 3.3/Dart 2.18. -* Added iOS exception on incorrect asset path +* Adds iOS exception on incorrect asset path ## 2.4.6 From 3b1a4c296a577f05ba198c9ac0800d3adca9649a Mon Sep 17 00:00:00 2001 From: Zaldy Jr Pagaduan Date: Thu, 29 Jun 2023 13:55:35 +0800 Subject: [PATCH 3/7] added incorrect asset test --- .../test/avfoundation_video_player_test.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart index 1b25da8bbaa..0d3625a343a 100644 --- a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart +++ b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart @@ -135,6 +135,15 @@ void main() { expect(textureId, 3); }); + test('create with incorrect asset', () async { + try { + await player.create(DataSource(sourceType: DataSourceType.asset)); + fail('should throw PlatformException'); + } catch (e) { + expect(e, isException); + } + }); + test('create with network', () async { final int? textureId = await player.create(DataSource( sourceType: DataSourceType.network, From f6456f3343224177bce35bf27fa22fa552dbd913 Mon Sep 17 00:00:00 2001 From: Zaldy Jr Pagaduan Date: Sat, 1 Jul 2023 08:42:52 +0800 Subject: [PATCH 4/7] updated test --- .../test/avfoundation_video_player_test.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart index 0d3625a343a..832980f424b 100644 --- a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart +++ b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart @@ -137,7 +137,10 @@ void main() { test('create with incorrect asset', () async { try { - await player.create(DataSource(sourceType: DataSourceType.asset)); + await player.create(DataSource( + sourceType: DataSourceType.asset, + asset: 'incorrectAsset', + )); fail('should throw PlatformException'); } catch (e) { expect(e, isException); From 5f1564b5117735d2ee6513ac531b7ad5499a58e0 Mon Sep 17 00:00:00 2001 From: Zaldy Jr Pagaduan Date: Tue, 4 Jul 2023 08:51:02 +0800 Subject: [PATCH 5/7] updated test --- .../test/avfoundation_video_player_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart index 832980f424b..745b65f76bc 100644 --- a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart +++ b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart @@ -139,7 +139,7 @@ void main() { try { await player.create(DataSource( sourceType: DataSourceType.asset, - asset: 'incorrectAsset', + asset: '/path/to/incorrect_asset', )); fail('should throw PlatformException'); } catch (e) { From 9e77817e7f2e65da40015acc64720065cd170d48 Mon Sep 17 00:00:00 2001 From: Zaldy Jr Pagaduan Date: Tue, 11 Jul 2023 20:59:25 +0800 Subject: [PATCH 6/7] ran format command --- .../ios/Classes/FLTVideoPlayerPlugin.m | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m b/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m index c9966d94427..ba45d4d3ea0 100644 --- a/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m +++ b/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m @@ -621,14 +621,13 @@ - (FLTTextureMessage *)create:(FLTCreateMessage *)input error:(FlutterError **)e assetPath = [_registrar lookupKeyForAsset:input.asset]; } @try { - player = [[FLTVideoPlayer alloc] initWithAsset:assetPath - frameUpdater:frameUpdater - playerFactory:_playerFactory]; - return [self onPlayerSetup:player frameUpdater:frameUpdater]; - } - @catch (NSException *exception) { - *error = [FlutterError errorWithCode:@"video_player" message:exception.reason details:nil]; - return nil; + player = [[FLTVideoPlayer alloc] initWithAsset:assetPath + frameUpdater:frameUpdater + playerFactory:_playerFactory]; + return [self onPlayerSetup:player frameUpdater:frameUpdater]; + } @catch (NSException *exception) { + *error = [FlutterError errorWithCode:@"video_player" message:exception.reason details:nil]; + return nil; } } else if (input.uri) { player = [[FLTVideoPlayer alloc] initWithURL:[NSURL URLWithString:input.uri] From 9e1c8f28050a8b247980dd5433dcdfa7506066e0 Mon Sep 17 00:00:00 2001 From: Zaldy Jr Pagaduan Date: Thu, 13 Jul 2023 09:50:41 +0800 Subject: [PATCH 7/7] updated test --- .../test/avfoundation_video_player_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart index 745b65f76bc..671256ae07f 100644 --- a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart +++ b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart @@ -135,7 +135,7 @@ void main() { expect(textureId, 3); }); - test('create with incorrect asset', () async { + test('create with incorrect asset throws exception', () async { try { await player.create(DataSource( sourceType: DataSourceType.asset,