Skip to Content
Author's profile photo Daniel Van Leeuwen

Getting Started with Kapsel – Part 20 — Voice Recording


Voice Recording Plugin (New in SP08)

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.  It takes the recorded audio file returned from the media capture plugin, encrypts it using an API from the encrypted storage plugin and then deletes the original unencrypted file.

For additional details on the Kapsel Voice Recording plugin see the JavaScript file in a project that includes this plugin at


or the Documentation at Using the Voice Recording Plugin.

The following steps will demonstrate these plugins.

  • Create the project.
    cordova -d create C:\Kapsel_Projects\VoiceRecordingDemo com.mycompany.voicerecording VoiceRecordingDemo "{\"plugin_search_path\":\"C:/SAP/MobileSDK3/KapselSDK/plugins/\"}"
    cd C:\Kapsel_Projects\VoiceRecordingDemo
    cordova -d platform add android
    cordova -d create ~/Documents/Kapsel_Projects/VoiceRecordingDemo com.mycompany.voicerecording VoiceRecordingDemo "{\"plugin_search_path\":\"/Users/i826567/SAP/MobileSDK3/KapselSDK/plugins/\"}"
    cd ~/Documents/Kapsel_Projects/VoiceRecordingDemo
    cordova -d platform add ios
  • Add the Media Capture plugin.
    cordova -d plugin add

    Add the attachment viewer plugin and two other plugins (should be automatically added as dependents but are not in SP08) to assist with the opening of the media file in a separate WebView.

    cordova plugins add
    cordova plugins add org.apache.cordova.dialogs
    cordova plugins add

    Modify the C:\Kapsel_Projects\VoiceRecordingDemo\plugins\\www\attachmentviewer.js file to handle file types.

    if (element.tagName == 'A' && (element.href.indexOf("http") === 0 || element.href.indexOf("https") === 0) && == "_blank")
    if (element.tagName == 'A' && (element.href.indexOf("http") === 0 || element.href.indexOf("file") === 0 || element.href.indexOf("https") === 0) && == "_blank")
  • Replace www\index.html with the contents of index.html.
  • Copy the files to the platform directory by running
    cordova -d prepare
  • Use the Android IDE or Xcode to deploy and run the project.

    Note, the Android emulator or iOS simulator can be used for this sample.  On Nexus devices, an app that can handle the intent android.provider.MediaStore.RECORD_SOUND will need to be installed.  One example is Sound Recorder by brightattic.


    Notice above that the file is unencrypted and accessible.

  • The following steps will add the Kapsel Voice Recording plugin which is used to encrypt the voice memo and then to delete the unencrypted file.
    cordova -d plugin add
  • Expose the deleteFile method by making the below changes to the file

    Move the exports section below the deleteFile method.  Modify the exports section to include the deleteFile method.

    module.exports = {
        audioCapture: audioCapture,
        deleteFile: deleteFile
  • Copy the files to the platform directory by running
    cordova -d prepare
  • Use the Android IDE or Xcode to deploy and run the project.

    This time click on the Using button to toggle to use the Kapsel Voice Recording plugin.
    Record a voice memo.  Notice that on the device storage, there is now an encrypted version of the voice recording.


    After pressing Unencrypt Voice Memo, an unencrypted copy is generated.


    Both files can be deleted by calling Delete Voice Memo.

Back to Getting Started With Kapsel

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Daniel Van Leeuwen
      Daniel Van Leeuwen
      Blog Post Author

      Updated for SMP 3.0 SDK SP08.  Note the UI of the recording screen changes in SP10.