Playing Native Audio Using Ionic Framework and Cordova

Written by on September 8, 2015

Playing Native Audio Using Ionic Framework and Cordova

Deployment

Next step, we need to build our application:

ionic build android

Be careful here, this step may break if you’re behind a firewall. The first execution will take a long time, so be patient.

When this step ends, look at the output log, last two lines should look something like this:

Built the following apk(s):
    D:\Development\IonicNativeAudioDemo\platforms\android\build\outputs\apk\android-debug.apk

We’ll use the last line location to deploy our application. Make sure your smartphone is prepared to accept an incoming application. In case of Android platform, you must enable Developer Options and USB Debugging.

Do this:

adb install -r platforms\android\build\outputs\apk\android-debug.apk

or you can do it like this:

ionic run android -l -c -s

Download The Code

You can download this example at GitHub:

GitHub Download
Categories

25 thoughts on “Playing Native Audio Using Ionic Framework and Cordova”

  1. Great write up (as always)!

    Thanks for providing these examples for us! I’ve made a habit to visit regularly to see what you’re writing about! Your site is a very valuable resource for Ionic Framework developers!

    Keep up the great work!

  2. i have problem here,,there is no output sound when i click the play button. It just like when i click blank (#) html link without some address. it not do anything.

    • After messing with this on both Android and iOS, are you currently trying to test this on iOS 9? Because apparently there is a bug on iOS 9 that has some issues with playing back audio on the device, both in the iOS emulator and on the iOS device, I’ve been testing this on iPhone 6s plus. I still haven’t figured this one yet, but I did want to make this known.

  3. is it necessary to unload every sound after played? shounldn’t afect that to the memory if the user listens same song various times?

  4. Justing wondering if this plugin (cordova-plugin-nativeaudio) can be used for streaming live audio instead of local media files?

  5. How to catch onended event native audio plugin? I need to catch the events when playing is ended. I have tried onended; but it is not working. Can You suggest me how I can do this?

Leave a Reply