Personally, I haven't used the Media plugin yet, but to handle background streams you will need to check which call warning calls.
For example, if this warning occurs when creating a Media object:
var my_media = new Media(src, onSuccess, onError);
Then you can check out the .js plugin file (which is Media.js ). Find the Media function and find your own call, which in this case:
exec(null, this.errorCallback, "Media", "create", [this.id, this.src]);
From this, you know that it calls the Media class create method.
So go and open Media.m (or CDVSound.m in this exact case) and find the create method (you should find it in cordova/plugins/org.apache.cordova.media/src/ios ), complete the encapsulation of the whole method with help
[self.commandDelegate runInBackground:^{
This will create a background stream for the native media creation. It should look like this:
- (void)create:(CDVInvokedUrlCommand*)command { [self.commandDelegate runInBackground:^{ NSString* mediaId = [command.arguments objectAtIndex:0]; NSString* resourcePath = [command.arguments objectAtIndex:1]; CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:NO 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]]; [self.commandDelegate evalJs:jsString]; } else { CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; } }]; }