Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

Voice Recording Plugin (SP10+)

The Cordova Media Capture plugin provides the ability to capture Audio, Image and Video.  The Kapsel Voice Recording plugin provides the ability to record audio in an encrypted format and provides a SAPUI5 user interface to record and play back the audio.

Note that the API exposed by this plugin changed in SP10.  If you are using SP09 or SP08, see Voice Recording Plugin (New in SP08).

For additional details see C:\SAP\MobileSDK3\KapselSDK\docs\api\sap.VoiceRecording.html or the Documentation at Using the Voice Recording Plugin.

The following steps will demonstrate this plugin.

  • Create the project and add the voice recording plugin.
    cordova create C:\Kapsel_Projects\VoiceRecordingDemo com.mycompany.voicerecording VoiceRecordingDemo
    cd C:\Kapsel_Projects\VoiceRecordingDemo
    cordova platform add android
    cordova plugin add kapsel-plugin-voicerecording --searchpath %KAPSEL_HOME%/plugins

    cordova create ~/Documents/Kapsel_Projects/VoiceRecordingDemo com.mycompany.voicerecording VoiceRecordingDemo
    cd ~/Documents/Kapsel_Projects/VoiceRecordingDemo
    cordova platform add ios
    cordova plugin add kapsel-plugin-voicerecording --searchpath $KAPSEL_HOME/plugins
  • Replace www\index.html with the contents of index.html.

  • Prepare, build and deploy the app with the following commands.
    cordova run android
    or
    cordova run ios
    Note, the Android emulator or iOS simulator can be used for this sample.



    The last image was taken against an Android emulator where the file system can be viewed.  Notice above that the file is encrypted.  When playing it or after calling recording.getAsFile a copy of the unencrypted file is temporarily available.

  • Note that in SP10 PL04 and perhaps earlier PLs you may need to add the following line of code to prevent an error store not defined.
    //around line 722 in recording.js
    if (state.secureStoreOpen) {
        store = utils.getEncryptedStorage(); //add this line to prevent Can't find variable store errors after calling the recording.getAsFile method.
        store.decryptFile(
    On 7 inch Android devices or emulators, you may wish to tweak the code to prevent the orientation from changing when displaying the recording or playback screen.  This may be fixed already in a more recent SAPUI5 release.
    //around line 230 in screen.js
    beforeOpen: function() {
        //if (window.screen.hisap.ui.Device.system.phone) screen.lockOrientation("portrait");
        if ((window.screen.height < 600) || (window.screen.width < 600)) screen.lockOrientation("portrait");

Back to Getting Started With Kapsel

1 Comment