Commit fb146914 authored by ldeluca's avatar ldeluca
Browse files
parents ba498cba ea7b96bc
Loading
Loading
Loading
Loading

NOTICE

0 → 100644
+5 −0
Changes for NOTICE: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
Apache Cordova
Copyright 2012 The Apache Software Foundation

This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
+4 −0
Changes for RELEASENOTES.md: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -57,3 +57,7 @@
### 0.2.8 (Feb 05, 2014)
* Add preliminary support for Tizen.
* [CB-4755] Fix crash in Media.setVolume on iOS

### 0.2.9 (Feb 26, 2014)
* CB-6051 Update media plugin to work with new cdvfile:// urls
* CB-5748 Make sure that Media.onStatus is called when recording is started.
+2 −1
Changes for plugin.xml: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="org.apache.cordova.media"
    version="0.2.8">
    version="0.2.9">

    <name>Media</name>
    <description>Cordova Media Plugin</description>
    <license>Apache 2.0</license>
+21 −2
Changes for src/android/AudioHandler.java: 21 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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;

@@ -64,17 +66,34 @@ 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)));
            String target = args.getString(1);
            String fileUriStr;
            try {
                Uri targetUri = resourceApi.remapUri(Uri.parse(target));
                fileUriStr = targetUri.toString();
            } catch (IllegalArgumentException e) {
                fileUriStr = target;
            }
            this.startRecordingAudio(args.getString(0), FileHelper.stripFileProtocol(fileUriStr));
        }
        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)));
            String target = args.getString(1);
            String fileUriStr;
            try {
                Uri targetUri = resourceApi.remapUri(Uri.parse(target));
                fileUriStr = targetUri.toString();
            } catch (IllegalArgumentException e) {
                fileUriStr = target;
            }
            this.startPlayingAudio(args.getString(0), FileHelper.stripFileProtocol(fileUriStr));
        }
        else if (action.equals("seekToAudio")) {
            this.seekToAudio(args.getString(0), args.getInt(1));
+19 −1
Changes for src/ios/CDVSound.m: 19 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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
@@ -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];
@@ -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];
@@ -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];
@@ -561,6 +577,7 @@
                if (recordingSuccess) {
                    NSLog(@"Started recording audio sample '%@'", audioFile.resourcePath);
                    jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('org.apache.cordova.media.Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
                    [self.commandDelegate evalJs:jsString];
                }
            }
            
@@ -575,6 +592,7 @@
                    [self.avSession setActive:NO error:nil];
                }
                jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('org.apache.cordova.media.Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMsg]];
                [self.commandDelegate evalJs:jsString];
            }
        };