Is really cordova working with ionic ? Media Player

Hi ,

I am trying to play an mp3 file within the native browser have surfed across tutorials and tried to implement it but no luck at all.

Havent tried doing anything fancy just playing the file

Tried to play the file using both the options as shown below.

Option 1 :
$scope.playAudio = function(src) {

    var media = $cordovaMedia.newMedia(src).then(function success(){
        alert("Success");
    },function error(){
        
        alert("Error");
    });
        
    media.play();
    console.log("Came inside the platform");
}

Option 2 :
$scope.play1=function(){
var src="/android_asset/mp3/sample.mp3";
var media = new Media(src, null, null, mediaStatusCallback1);
console.log(“Cordova Media”+$cordovaMedia);
$cordovaMedia.play(media);
console.log(“Came inside the platform”);
}

var mediaStatusCallback = function(status) {
    if(status == 1) {
        $ionicLoading.show({template: 'Loading...'});
    } else {
        $ionicLoading.hide();
    }
}

   var mediaStatusCallback1 = function(status) {
    if(status == 1) {
        $ionicLoading.show({template: 'Loading...'});
    } else {
        $ionicLoading.hide();
    }
}

But no luck at all trying to execute it for a week.

in logcat found to see below stack trace.

D/CordovaLog(18521): file:///android_asset/www/js/controllers.js: Line 54 : Cordova Media[object Object]
I/chromium(18521): [INFO:CONSOLE(54)] “Cordova Media[object Object]”, source: file:///android_asset/www/js/controllers.js (54)
D/CordovaLog(18521): file:///android_asset/www/lib/ionic/js/ionic.bundle.js: Line 19890 : TypeError: Object # has no method 'play’
D/CordovaLog(18521): at Scope.$scope.play1 (file:///android_asset/www/js/controllers.js:55:23)
D/CordovaLog(18521): at $parseFunctionCall (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:20628:18)
D/CordovaLog(18521): at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:52854:9
D/CordovaLog(18521): at Scope.$eval (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:22684:28)
D/CordovaLog(18521): at Scope.$apply (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:22783:23)
D/CordovaLog(18521): at HTMLButtonElement. (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:52853:13)
D/CordovaLog(18521): at HTMLButtonElement.eventHandler (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:11297:21)
D/CordovaLog(18521): at triggerMouseEvent (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:2863:7)
D/CordovaLog(18521): at tapClick (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:2852:3)
D/CordovaLog(18521): at HTMLDocument.tapTouchEnd (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:2970:5)
I/chromium(18521): [INFO:CONSOLE(19890)] “TypeError: Object # has no method 'play’
I/chromium(18521): at Scope.$scope.play1 (file:///android_asset/www/js/controllers.js:55:23)
I/chromium(18521): at $parseFunctionCall (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:20628:18)
I/chromium(18521): at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:52854:9
I/chromium(18521): at Scope.$eval (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:22684:28)
I/chromium(18521): at Scope.$apply (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:22783:23)
I/chromium(18521): at HTMLButtonElement. (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:52853:13)
I/chromium(18521): at HTMLButtonElement.eventHandler (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:11297:21)
I/chromium(18521): at triggerMouseEvent (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:2863:7)
I/chromium(18521): at tapClick (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:2852:3)
I/chromium(18521): at HTMLDocument.tapTouchEnd (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:2970:5)”, source: file:///android_asset/www/lib/ionic/js/ionic.bundle.js (19890)
I/ProcessStatsService( 1265): Prepared write state in 1ms
I/ProcessStatsService( 1265): Prepared write state in 0ms

Any Help is really appreciated.

install cordova plugin : cordova plugin add org.apache.cordova.media
$scope.play = function(src)
{
var media = new Media(src, null, null, mediaStatusCallback);
media.play();
//$cordovaMedia.play(media); tested many times individually working but… in our project not working
}

    var mediaStatusCallback = function(status)
    {
        if(status == 1)
        {
            $ionicLoading.show({template: 'Loading...'});
        } else
        {
            $ionicLoading.hide();
        }
    }