This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/cordova-plugin-media-capture.git
The following commit(s) were added to refs/heads/master by this push:
new 7d1701d fix(ios): set type attribute for captured audio (#197)
7d1701d is described below
commit 7d1701db3499f7321e11e5df3e8358edde9cc395
Author: Alexis THOMAS <[email protected]>
AuthorDate: Mon Aug 7 16:43:36 2023 +0200
fix(ios): set type attribute for captured audio (#197)
* fix(ios): always set "type" for mediaDictionary, from param or determined
from file
If the 'type' param was provided, the fileDict was missing its mimeType
value.
* fix(ios): determine captured audio type from file instead of hardcoded
value
Previously forced "audio/wav" but not always correct: from file can be
"audio/x-wav" or other.
---
src/ios/CDVCapture.m | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/ios/CDVCapture.m b/src/ios/CDVCapture.m
index cf9b17e..500f075 100644
--- a/src/ios/CDVCapture.m
+++ b/src/ios/CDVCapture.m
@@ -502,7 +502,7 @@
- (NSDictionary*)getMediaDictionaryFromPath:(NSString*)fullPath
ofType:(NSString*)type
{
NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSMutableDictionary* fileDict = [NSMutableDictionary
dictionaryWithCapacity:5];
+ NSMutableDictionary* fileDict = [NSMutableDictionary
dictionaryWithCapacity:6];
CDVFile *fs = [self.commandDelegate getCommandInstance:@"File"];
@@ -519,14 +519,15 @@
[fileDict setObject:[url absoluteURL] forKey:@"localURL"];
}
// determine type
- if (!type) {
+ NSString* mimeType = type;
+ if (!mimeType) {
id command = [self.commandDelegate getCommandInstance:@"File"];
if ([command isKindOfClass:[CDVFile class]]) {
CDVFile* cdvFile = (CDVFile*)command;
- NSString* mimeType = [cdvFile getMimeTypeFromPath:fullPath];
- [fileDict setObject:(mimeType != nil ? (NSObject*)mimeType :
[NSNull null]) forKey:@"type"];
+ mimeType = [cdvFile getMimeTypeFromPath:fullPath];
}
}
+ [fileDict setObject:(mimeType != nil ? (NSObject*)mimeType : [NSNull
null]) forKey:@"type"];
NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:fullPath
error:nil];
[fileDict setObject:[NSNumber numberWithUnsignedLongLong:[fileAttrs
fileSize]] forKey:@"size"];
NSDate* modDate = [fileAttrs fileModificationDate];
@@ -926,7 +927,7 @@
if (flag) {
NSString* filePath = [avRecorder.url path];
// NSLog(@"filePath: %@", filePath);
- NSDictionary* fileDict = [captureCommand
getMediaDictionaryFromPath:filePath ofType:@"audio/wav"];
+ NSDictionary* fileDict = [captureCommand
getMediaDictionaryFromPath:filePath ofType:nil];
NSArray* fileArray = [NSArray arrayWithObject:fileDict];
self.pluginResult = [CDVPluginResult
resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]