Question

Im a bit new to Sencha (sencha touch 2.3.0) so maybe this is easy:)

Trying to Capture(Record) audio on a android app created with Sencha. There are no Error msg in console, so it does not reach the success or the failure.. Looked at http://docs.sencha.com/touch/2.3.0/#!/api/Ext.device.Capture

The view:

Ext.define('MyApp.view.Start.Dictaphone', {
extend: 'Ext.form.FieldSet',
xtype: 'dictaphone',


requires: [
    'Ext.form.FormPanel',
    'Ext.device.Capture',
    'Ext.device.Notification'
],
config: {
    title: "recordings",
    items: [
        {
            xtype: 'label',
            html: 'Press button for recording',
            padding: 10
        },
        {
            xtype: 'formpanel',
            itemId: 'searchPanel',
            scrollable: null,
            items: [
                 {
                     xtype: 'button',
                     margin: '15 30 30 30',
                     text: 'start audio recording',
                     cls: 'bigButton',
                     itemId: 'recordAudioBtn'
                 },
                 {
                     xtype: 'button',
                     margin: '15 30 30 30',
                     text: 'notifiy me',
                     cls: 'bigButton',
                     itemId: 'testy'
                 }
            ]
        }
    ]
}});

The Controller:

Ext.define('MyApp.controller.Start.DictaphoneController', {
extend: 'Ext.app.Controller',


config: {
    refs: {
        vp: '#mainViewPort',
        startView: 'start',
        testBar: '#mainViewPort #testBar',
        recordAudioBtn: 'dictaphone #recordAudioBtn',
        testyBtn: 'dictaphone #testy'
    },
    control: {
        recordAudioBtn: {
            tap: 'onRecordAudioBtnClick'
        },
        testyBtn: {
            tap: 'onTestyClick'
        }
    }
},

//Event handlers
onRecordAudioBtnClick: function () {
      Ext.device.Capture.captureAudio({
        limit: 2, // limit to 2 recordings
        maximumDuration: 10, // limit to 10 seconds per recording
        success: function (files) {
            for (var i = 0; i < files.length; i++) {
                console.log('Captured audio path: ', files[i].fullPath);
            };
        },
        failure: function () {
            console.log('Something went wrong!');
        }
    }); 
},

//Event handlers
onTestyClick: function () {
    Ext.device.Notification.show({
        title: 'Verification',
        message: 'Is your email address is: test@sencha.com',
        buttons: Ext.MessageBox.OKCANCEL,
        callback: function(button) {
            if (button == "ok") {
                console.log('Verified');
            } else {
                console.log('Nope.');
            }
        }
    });

}});

Have set permissons in manifest to :

<uses-permission android:name="android.permission.INTERNET" />   
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Building with: sencha app build package

The Notification works fine, but nothing at all happends when pushing record audio button.. Suggestions?

Was it helpful?

Solution

As i suspected it was a easy solution. Not all native functionality is supported directly by sencha, so i had to initialize Cordova in my project.

And this is how:

1.First the init of cordova to the prosject:

sencha cordova init com.app.myapp MyApp

2.Then change the cordova.local.properties to build for android:

cordova.platforms=android

3.Step into the cordova folder and add the capture plugin:

cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git

4.Build the app

sencha app build -run native
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top