cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alsoro...@apache.org
Subject cordova-plugin-media git commit: CB-11380 (ios) Fixed an unexpected error callback when initializing Media with file that doesn't exist
Date Fri, 26 Aug 2016 08:49:48 GMT
Repository: cordova-plugin-media
Updated Branches:
  refs/heads/master 948fe3597 -> 910d3c798


CB-11380 (ios) Fixed an unexpected error callback when initializing Media with file that doesn't
exist


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/commit/910d3c79
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/tree/910d3c79
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/diff/910d3c79

Branch: refs/heads/master
Commit: 910d3c798f77c63165be508125ec313e4104b541
Parents: 948fe35
Author: Alexander Sorokin <alexander.sorokin@akvelon.com>
Authored: Thu Aug 25 14:21:41 2016 +0300
Committer: Alexander Sorokin <alexander.sorokin@akvelon.com>
Committed: Fri Aug 26 11:24:37 2016 +0300

----------------------------------------------------------------------
 src/ios/CDVSound.m | 10 +++++-----
 tests/tests.js     | 31 ++++++++++++-------------------
 2 files changed, 17 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/910d3c79/src/ios/CDVSound.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVSound.m b/src/ios/CDVSound.m
index 1b1f568..ddb524e 100644
--- a/src/ios/CDVSound.m
+++ b/src/ios/CDVSound.m
@@ -131,7 +131,7 @@
 }
 
 // Creates or gets the cached audio file resource object
-- (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)mediaId doValidation:(BOOL)bValidate
forRecording:(BOOL)bRecord
+- (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)mediaId doValidation:(BOOL)bValidate
forRecording:(BOOL)bRecord suppressValidationErrors:(BOOL)bSuppress
 {
     BOOL bError = NO;
     CDVMediaError errcode = MEDIA_ERR_NONE_SUPPORTED;
@@ -164,7 +164,7 @@
         } else {
             resourceURL = [self urlForPlaying:resourcePath];
         }
-        if (resourceURL == nil) {
+        if ((resourceURL == nil) && !bSuppress) {
             bError = YES;
             errcode = MEDIA_ERR_ABORTED;
             errMsg = [NSString stringWithFormat:@"Cannot use audio file from resource '%@'",
resourcePath];
@@ -217,7 +217,7 @@
     NSString* mediaId = [command argumentAtIndex:0];
     NSString* resourcePath = [command argumentAtIndex:1];
 
-    CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:YES
forRecording:NO];
+    CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:YES
forRecording:NO suppressValidationErrors:YES];
 
     if (audioFile == nil) {
         NSString* errorMessage = [NSString stringWithFormat:@"Failed to initialize Media
file with path %@", resourcePath];
@@ -313,7 +313,7 @@
     BOOL bError = NO;
     NSString* jsString = nil;
 
-    CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:YES
forRecording:NO];
+    CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:YES
forRecording:NO suppressValidationErrors:NO];
     if ((audioFile != nil) && (audioFile.resourceURL != nil)) {
         if (audioFile.player == nil) {
             bError = [self prepareToPlay:audioFile withId:mediaId];
@@ -636,7 +636,7 @@
 #pragma unused(callbackId)
 
     NSString* mediaId = [command argumentAtIndex:0];
-    CDVAudioFile* audioFile = [self audioFileForResource:[command argumentAtIndex:1] withId:mediaId
doValidation:YES forRecording:YES];
+    CDVAudioFile* audioFile = [self audioFileForResource:[command argumentAtIndex:1] withId:mediaId
doValidation:YES forRecording:YES suppressValidationErrors:NO];
     __block NSString* jsString = nil;
     __block NSString* errorMsg = @"";
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/910d3c79/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index d9b9de3..d627221 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -685,15 +685,14 @@ exports.defineManualTests = function (contentEl, createActionButton)
{
 
     //Record audio
     function recordAudio() {
-        console.log("recordAudio()");
+        console.log("recordAudio(), recording to " + recordSrc);
         console.log(" -- media=" + mediaRec);
 
         releaseAudio();
 
         if (!mediaRec) {
-            var src = recordSrc;
-            mediaRec = new Media(src,
-                    function () {
+            mediaRec = new Media(recordSrc,
+                function () {
                     console.log("recordAudio():Audio Success");
                 },
                     function (err) {
@@ -731,22 +730,16 @@ exports.defineManualTests = function (contentEl, createActionButton)
{
         playAudio(recordSrc);
     }
 
-    //Function to create a file for iOS recording
-
+    //Function to get a filename for iOS recording
+    //Ensures that file doesn't exist to test CB-11380
     function getRecordSrc() {
-        var fsFail = function (error) {
-            console.log("error creating file for iOS recording");
-        };
-        var gotFile = function (file) {
-            recordSrc = file.fullPath;
-            //console.log("recording Src: " + recordSrc);
-        };
-        var gotFS = function (fileSystem) {
-            fileSystem.root.getFile("iOSRecording.wav", {
-                create : true
-            }, gotFile, fsFail);
-        };
-        window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fsFail);
+        var noop = function () {};
+        recordSrc = "cdvfile://localhost/temporary/iOSRecording.wav";
+        window.resolveLocalFileSystemURL(recordSrc, function (file) {
+            file.remove(function() {
+                console.log("Successfully removed " + recordSrc);
+            }, noop);
+        }, noop);
     }
 
     //Function to create a file for BB recording


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message