Skip to content
Permalink
Browse files

temp fix for ios8 file:// bug - moved reference to Documents director…

…y into CDVSound class
  • Loading branch information...
shi11 committed Oct 7, 2014
1 parent 11beb0b commit ee7c99181d276c63eb74c2ac2cafaee6beb4a25e
Showing with 10 additions and 5 deletions.
  1. +10 −5 src/ios/CDVSound.m
@@ -262,9 +262,11 @@ - (void)create:(CDVInvokedUrlCommand*)command
{
NSString* mediaId = [command.arguments objectAtIndex:0];
NSString* resourcePath = [command.arguments objectAtIndex:1];

CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:NO forRecording:NO];

NSString* basePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *fullPath = [NSString stringWithFormat:@"%@%@", basePath, resourcePath];

CDVAudioFile* audioFile = [self audioFileForResource:fullPath withId:mediaId doValidation:YES forRecording:NO];

if (audioFile == nil) {
NSString* errorMessage = [NSString stringWithFormat:@"Failed to initialize Media file with path %@", resourcePath];
NSString* jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('org.apache.cordova.media.Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMessage]];
@@ -305,11 +307,14 @@ - (void)startPlayingAudio:(CDVInvokedUrlCommand*)command
NSString* mediaId = [command.arguments objectAtIndex:0];
NSString* resourcePath = [command.arguments objectAtIndex:1];
NSDictionary* options = [command.arguments objectAtIndex:2 withDefault:nil];

NSString* basePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *fullPath = [NSString stringWithFormat:@"%@%@", basePath, resourcePath];

BOOL bError = NO;
NSString* jsString = nil;

CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:YES forRecording:NO];
CDVAudioFile* audioFile = [self audioFileForResource:fullPath withId:mediaId doValidation:YES forRecording:NO];
if ((audioFile != nil) && (audioFile.resourceURL != nil)) {
if (audioFile.player == nil) {
bError = [self prepareToPlay:audioFile withId:mediaId];
@@ -743,4 +748,4 @@ @implementation CDVAudioPlayer
@implementation CDVAudioRecorder
@synthesize mediaId;

@end
@end

0 comments on commit ee7c991

Please sign in to comment.
You can’t perform that action at this time.