mirror of
https://github.com/flutter/packages.git
synced 2025-06-30 23:03:11 +08:00
[video_player] added iOS exception on incorrect asset path (#4318)
surfaced the incorrect asset path error to dart using try catch. Fixes [#118660](https://github.com/flutter/flutter/issues/118660)
This commit is contained in:

committed by
GitHub

parent
77bb4d930d
commit
4c1149744d
@ -1,6 +1,7 @@
|
|||||||
## NEXT
|
## 2.4.7
|
||||||
|
|
||||||
* Updates minimum supported SDK version to Flutter 3.3/Dart 2.18.
|
* Updates minimum supported SDK version to Flutter 3.3/Dart 2.18.
|
||||||
|
* Adds iOS exception on incorrect asset path
|
||||||
|
|
||||||
## 2.4.6
|
## 2.4.6
|
||||||
|
|
||||||
|
@ -620,10 +620,15 @@ NS_INLINE UIViewController *rootViewController(void) {
|
|||||||
} else {
|
} else {
|
||||||
assetPath = [_registrar lookupKeyForAsset:input.asset];
|
assetPath = [_registrar lookupKeyForAsset:input.asset];
|
||||||
}
|
}
|
||||||
player = [[FLTVideoPlayer alloc] initWithAsset:assetPath
|
@try {
|
||||||
frameUpdater:frameUpdater
|
player = [[FLTVideoPlayer alloc] initWithAsset:assetPath
|
||||||
playerFactory:_playerFactory];
|
frameUpdater:frameUpdater
|
||||||
return [self onPlayerSetup:player 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) {
|
} else if (input.uri) {
|
||||||
player = [[FLTVideoPlayer alloc] initWithURL:[NSURL URLWithString:input.uri]
|
player = [[FLTVideoPlayer alloc] initWithURL:[NSURL URLWithString:input.uri]
|
||||||
frameUpdater:frameUpdater
|
frameUpdater:frameUpdater
|
||||||
|
@ -2,7 +2,7 @@ name: video_player_avfoundation
|
|||||||
description: iOS implementation of the video_player plugin.
|
description: iOS implementation of the video_player plugin.
|
||||||
repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_avfoundation
|
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
|
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:
|
environment:
|
||||||
sdk: ">=2.18.0 <4.0.0"
|
sdk: ">=2.18.0 <4.0.0"
|
||||||
|
@ -135,6 +135,18 @@ void main() {
|
|||||||
expect(textureId, 3);
|
expect(textureId, 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('create with incorrect asset throws exception', () async {
|
||||||
|
try {
|
||||||
|
await player.create(DataSource(
|
||||||
|
sourceType: DataSourceType.asset,
|
||||||
|
asset: '/path/to/incorrect_asset',
|
||||||
|
));
|
||||||
|
fail('should throw PlatformException');
|
||||||
|
} catch (e) {
|
||||||
|
expect(e, isException);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('create with network', () async {
|
test('create with network', () async {
|
||||||
final int? textureId = await player.create(DataSource(
|
final int? textureId = await player.create(DataSource(
|
||||||
sourceType: DataSourceType.network,
|
sourceType: DataSourceType.network,
|
||||||
|
Reference in New Issue
Block a user