From 295207826a37ce44d3c1d20cc0d3857a5d04ceec Mon Sep 17 00:00:00 2001 From: canxin Date: Sun, 5 May 2024 02:46:13 +0800 Subject: [PATCH 1/2] [Fix] preferPreciseDurationAndTiming config unused in file Uri --- just_audio/darwin/Classes/UriAudioSource.m | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/just_audio/darwin/Classes/UriAudioSource.m b/just_audio/darwin/Classes/UriAudioSource.m index 28029daf5..73073301d 100644 --- a/just_audio/darwin/Classes/UriAudioSource.m +++ b/just_audio/darwin/Classes/UriAudioSource.m @@ -32,10 +32,20 @@ - (NSString *)uri { - (IndexedPlayerItem *)createPlayerItem:(NSString *)uri { IndexedPlayerItem *item; + NSMutableDictionary *assetOptions = [[NSMutableDictionary alloc] init]; + + if (_options != (id)[NSNull null]) { + NSDictionary *darwinOptions = _options[@"darwinAssetOptions"]; + if (darwinOptions != (id)[NSNull null]) { + assetOptions[AVURLAssetPreferPreciseDurationAndTimingKey] = darwinOptions[@"preferPreciseDurationAndTiming"]; + } + } + if ([uri hasPrefix:@"file://"]) { - item = [[IndexedPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:[[uri stringByRemovingPercentEncoding] substringFromIndex:7]]]; + NSURL *fileURL = [NSURL fileURLWithPath:[[uri stringByRemovingPercentEncoding] substringFromIndex:7]]; + AVURLAsset *asset = [AVURLAsset URLAssetWithURL:fileURL options:assetOptions]; + item = [[IndexedPlayerItem alloc] initWithAsset:asset]; } else { - NSMutableDictionary *assetOptions = [[NSMutableDictionary alloc] init]; if (_headers) { // Use user-agent key if it is the only header and the API is supported. if ([_headers count] == 1) { @@ -58,13 +68,7 @@ - (IndexedPlayerItem *)createPlayerItem:(NSString *)uri { assetOptions[@"AVURLAssetHTTPHeaderFieldsKey"] = _headers; } } - if (_options != (id)[NSNull null]) { - NSDictionary *darwinOptions = _options[@"darwinAssetOptions"]; - if (darwinOptions != (id)[NSNull null]) { - assetOptions[AVURLAssetPreferPreciseDurationAndTimingKey] = darwinOptions[@"preferPreciseDurationAndTiming"]; - } - } - + AVURLAsset *asset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:uri] options:assetOptions]; item = [[IndexedPlayerItem alloc] initWithAsset:asset]; } From 63a52fa1cf3bb067377ac89a97f38bd58ba8fe53 Mon Sep 17 00:00:00 2001 From: Ryan Heise Date: Sun, 26 May 2024 23:17:59 +1000 Subject: [PATCH 2/2] Update changelog and version. --- just_audio/CHANGELOG.md | 4 +++ .../ios/Runner.xcodeproj/project.pbxproj | 34 +++++++++++++++++-- just_audio/pubspec.yaml | 2 +- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/just_audio/CHANGELOG.md b/just_audio/CHANGELOG.md index 88bc3dd68..d591eab4c 100644 --- a/just_audio/CHANGELOG.md +++ b/just_audio/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.9.39 + +* Apply preferPreciseDurationAndTiming to files (@canxin121). + ## 0.9.38 * Migrate to package:web. diff --git a/just_audio/example/ios/Runner.xcodeproj/project.pbxproj b/just_audio/example/ios/Runner.xcodeproj/project.pbxproj index 6fc933a60..fed952262 100644 --- a/just_audio/example/ios/Runner.xcodeproj/project.pbxproj +++ b/just_audio/example/ios/Runner.xcodeproj/project.pbxproj @@ -150,6 +150,7 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + E3D27207363A6BEE407ADF2D /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -261,6 +262,24 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + E3D27207363A6BEE407ADF2D /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/path_provider_foundation/path_provider_foundation_privacy.bundle", + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/path_provider_foundation_privacy.bundle", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -358,7 +377,10 @@ ); INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -486,7 +508,10 @@ ); INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -510,7 +535,10 @@ ); INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", diff --git a/just_audio/pubspec.yaml b/just_audio/pubspec.yaml index 9933a40d9..7b2a0f926 100644 --- a/just_audio/pubspec.yaml +++ b/just_audio/pubspec.yaml @@ -1,6 +1,6 @@ name: just_audio description: A feature-rich audio player for Flutter. Loop, clip and concatenate any sound from any source (asset/file/URL/stream) in a variety of audio formats with gapless playback. -version: 0.9.38 +version: 0.9.39 repository: https://github.com/ryanheise/just_audio/tree/minor/just_audio issue_tracker: https://github.com/ryanheise/just_audio/issues topics: