I seem to be having problems with a view in my Ionic project. This particular view uses $cordovaMedia to play a wav file under the user’s control.
Now, when the user move ‘< Back’ to the previous view or chooses another tab, I want the $cordovaMedia object to stop playing and unload.
I have included the following code on in my controller:
$scope.$on("$destroy"), function() {
$cordovaMedia.stop(media);
$cordovaMedia.release(media);
};
However, when I leave the page, the media keeps playing, and I notice in XCode that the memory usage remains high - so I assume the object is not being stopped and destroyed as I want.
I have also specified ‘cache: false’ in the main state setup:
.state('app.player', {
cache: false,
url: "/recording/:recordingId",
views: {
'menuContent': {
templateUrl: "templates/player.html",
controller: 'PlayerCtrl'
}
}
})
I have even tried $scope.$on("$locationChangeStart") instead of “$destroy” to see if that would work, but no difference.
I’d appreciate it if anyone could point out where I am going wrong? Thanks.