Loading src/android/AudioHandler.java +7 −2 Changes for src/android/AudioHandler.java: 7 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -20,9 +20,11 @@ package org.apache.cordova.media; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CordovaResourceApi; import android.content.Context; import android.media.AudioManager; import android.net.Uri; import java.util.ArrayList; Loading Loading @@ -64,17 +66,20 @@ public class AudioHandler extends CordovaPlugin { * @return A PluginResult object with a status and message. */ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { CordovaResourceApi resourceApi = webView.getResourceApi(); PluginResult.Status status = PluginResult.Status.OK; String result = ""; if (action.equals("startRecordingAudio")) { this.startRecordingAudio(args.getString(0), FileHelper.stripFileProtocol(args.getString(1))); Uri fileUri = resourceApi.remapUri(Uri.parse(args.getString(1))); this.startRecordingAudio(args.getString(0), FileHelper.stripFileProtocol(fileUri.toString())); } else if (action.equals("stopRecordingAudio")) { this.stopRecordingAudio(args.getString(0)); } else if (action.equals("startPlayingAudio")) { this.startPlayingAudio(args.getString(0), FileHelper.stripFileProtocol(args.getString(1))); Uri fileUri = resourceApi.remapUri(Uri.parse(args.getString(1))); this.startPlayingAudio(args.getString(0), FileHelper.stripFileProtocol(fileUri.toString())); } else if (action.equals("seekToAudio")) { this.seekToAudio(args.getString(0), args.getInt(1)); Loading src/ios/CDVSound.m +17 −1 Changes for src/ios/CDVSound.m: 17 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -18,12 +18,14 @@ */ #import "CDVSound.h" #import "CDVFile.h" #import <Cordova/NSArray+Comparisons.h> #import <Cordova/CDVJSON.h> #define DOCUMENTS_SCHEME_PREFIX @"documents://" #define HTTP_SCHEME_PREFIX @"http://" #define HTTPS_SCHEME_PREFIX @"https://" #define CDVFILE_PREFIX @"cdvfile://" #define RECORDING_WAV @"wav" @implementation CDVSound Loading Loading @@ -85,6 +87,13 @@ // try to find Documents:// resources filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/", docsPath]]; NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath); } else if ([resourcePath hasPrefix:CDVFILE_PREFIX]) { CDVFile *filePlugin = [self.commandDelegate getCommandInstance:@"File"]; CDVFilesystemURL *url = [CDVFilesystemURL fileSystemURLWithString:resourcePath]; filePath = [filePlugin filesystemPathForURL:url]; if (filePath == nil) { resourceURL = [NSURL URLWithString:resourcePath]; } } else { // if resourcePath is not from FileSystem put in tmp dir, else attempt to use provided resource path NSString* tmpPath = [NSTemporaryDirectory()stringByStandardizingPath]; Loading Loading @@ -122,6 +131,13 @@ NSString* docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/", docsPath]]; NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath); } else if ([resourcePath hasPrefix:CDVFILE_PREFIX]) { CDVFile *filePlugin = [self.commandDelegate getCommandInstance:@"File"]; CDVFilesystemURL *url = [CDVFilesystemURL fileSystemURLWithString:resourcePath]; filePath = [filePlugin filesystemPathForURL:url]; if (filePath == nil) { resourceURL = [NSURL URLWithString:resourcePath]; } } else { // attempt to find file path in www directory or LocalFileSystem.TEMPORARY directory filePath = [self.commandDelegate pathForResource:resourcePath]; Loading @@ -141,7 +157,7 @@ NSLog(@"Found resource '%@' in the web folder.", filePath); } } // check that file exists for all but HTTP_SHEME_PREFIX // if the resourcePath resolved to a file path, check that file exists if (filePath != nil) { // create resourceURL resourceURL = [NSURL fileURLWithPath:filePath]; Loading Loading
src/android/AudioHandler.java +7 −2 Changes for src/android/AudioHandler.java: 7 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -20,9 +20,11 @@ package org.apache.cordova.media; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CordovaResourceApi; import android.content.Context; import android.media.AudioManager; import android.net.Uri; import java.util.ArrayList; Loading Loading @@ -64,17 +66,20 @@ public class AudioHandler extends CordovaPlugin { * @return A PluginResult object with a status and message. */ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { CordovaResourceApi resourceApi = webView.getResourceApi(); PluginResult.Status status = PluginResult.Status.OK; String result = ""; if (action.equals("startRecordingAudio")) { this.startRecordingAudio(args.getString(0), FileHelper.stripFileProtocol(args.getString(1))); Uri fileUri = resourceApi.remapUri(Uri.parse(args.getString(1))); this.startRecordingAudio(args.getString(0), FileHelper.stripFileProtocol(fileUri.toString())); } else if (action.equals("stopRecordingAudio")) { this.stopRecordingAudio(args.getString(0)); } else if (action.equals("startPlayingAudio")) { this.startPlayingAudio(args.getString(0), FileHelper.stripFileProtocol(args.getString(1))); Uri fileUri = resourceApi.remapUri(Uri.parse(args.getString(1))); this.startPlayingAudio(args.getString(0), FileHelper.stripFileProtocol(fileUri.toString())); } else if (action.equals("seekToAudio")) { this.seekToAudio(args.getString(0), args.getInt(1)); Loading
src/ios/CDVSound.m +17 −1 Changes for src/ios/CDVSound.m: 17 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -18,12 +18,14 @@ */ #import "CDVSound.h" #import "CDVFile.h" #import <Cordova/NSArray+Comparisons.h> #import <Cordova/CDVJSON.h> #define DOCUMENTS_SCHEME_PREFIX @"documents://" #define HTTP_SCHEME_PREFIX @"http://" #define HTTPS_SCHEME_PREFIX @"https://" #define CDVFILE_PREFIX @"cdvfile://" #define RECORDING_WAV @"wav" @implementation CDVSound Loading Loading @@ -85,6 +87,13 @@ // try to find Documents:// resources filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/", docsPath]]; NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath); } else if ([resourcePath hasPrefix:CDVFILE_PREFIX]) { CDVFile *filePlugin = [self.commandDelegate getCommandInstance:@"File"]; CDVFilesystemURL *url = [CDVFilesystemURL fileSystemURLWithString:resourcePath]; filePath = [filePlugin filesystemPathForURL:url]; if (filePath == nil) { resourceURL = [NSURL URLWithString:resourcePath]; } } else { // if resourcePath is not from FileSystem put in tmp dir, else attempt to use provided resource path NSString* tmpPath = [NSTemporaryDirectory()stringByStandardizingPath]; Loading Loading @@ -122,6 +131,13 @@ NSString* docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/", docsPath]]; NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath); } else if ([resourcePath hasPrefix:CDVFILE_PREFIX]) { CDVFile *filePlugin = [self.commandDelegate getCommandInstance:@"File"]; CDVFilesystemURL *url = [CDVFilesystemURL fileSystemURLWithString:resourcePath]; filePath = [filePlugin filesystemPathForURL:url]; if (filePath == nil) { resourceURL = [NSURL URLWithString:resourcePath]; } } else { // attempt to find file path in www directory or LocalFileSystem.TEMPORARY directory filePath = [self.commandDelegate pathForResource:resourcePath]; Loading @@ -141,7 +157,7 @@ NSLog(@"Found resource '%@' in the web folder.", filePath); } } // check that file exists for all but HTTP_SHEME_PREFIX // if the resourcePath resolved to a file path, check that file exists if (filePath != nil) { // create resourceURL resourceURL = [NSURL fileURLWithPath:filePath]; Loading