I can't comprehend why individuals suggest the vanilla/ng audio techniques. With Ionic Framework involved, it's crucial to opt for Cordova in order for compatibility on all devices like iOS, Android, Windows Phone, etc.
Utilize the Cordova Media plugin (ensure that you have ngCordova
installed and included in your index.html file, along with defining it as a dependency). Inject $cordovaMedia
into the controller/service.
In your controller:
$scope.myMedia = $cordovaMedia.newMedia('audio/song.mp3'); // It should be relative to index.html for proper functioning on Android
In your view:
<button class="button button-positive" ng-click="myMedia.play()">
Play sound!
</button>
<button class="button button-assertive" ng-click="myMedia.stop()">
Stop sound!
</button>