iCediCe
iCediCe

Reputation: 1723

Ionic native using ionic/angular 1

I'm currently working on a project in ionic/angular 1. I'm using ionic native to wrap the cordova plugins.

I installed ionic native with bower, and added dependency to 'ionic.native' in my app's angular module. Now I can inject stuff like $cordovaFile into my controllers and use them. This works great.

My problem is using the MediaPlugin. I inject $cordovaMediaPlugin in my controller. Now the documentation ( https://ionicframework.com/docs/v2/native/mediaplugin/ ) says do this:

new MediaPlugin('path/to/file.mp3', onStatusUpdate);

Obviously i cant do this in angular1.

I tried stuff like this:

var media = this.$cordovaMediaPlugin('PATH'); var media = new this.$cordovaMediaPlugin('patch');

nothing seems to work, getting undefined all the time.

How would I make this calls in angular/ionic 1? I really think the 'new' keyword is the issue here...

Upvotes: 3

Views: 273

Answers (1)

phdias
phdias

Reputation: 215

Try to install ngCordova Media plugin.

Install ngCordova, and inject in your app module 'ngCordova'.

  1. See de following steps

  2. Install plugin

  3. If you want create a service to provide a media resources see (Not required)

Upvotes: 0

Related Questions