ionic2 - media-plugin-with-compression - TypeError: window.Media is not a constructor -


this plugin: media-with-compression worked few days ago, i'm getting when try record: exception: uncaught (in promise): typeerror: window.media not constructor

i have declared:

declare var window: any; declare var media: any; 

and using way:

 this.audiofile = new window.media(this.audiodirectory + this.audioname,           ..... 

i don't know if because new version of @ionic-native, or happened, didn't touch code weeks , not working.

any clue if new versions of @ionic-native, non native plugins working different?

thank you!

you cannot run on browser.you have run on actual device.

here can see how set path.ios media plugin

the trick on ios , android use .tointernalurl() instead of .tourl() on file object. code work on both platforms:

window.requestfilesystem(     localfilesystem.persistent,     0,     function(filesystem) {         filesystem.root.getdirectory('app-data/main-packages/en/', {create: false}, function(sourcedir){             sourcedir.getfile('2.mp3', {create: false}, function(file){                 console.log('file url: ', file.tointernalurl());                 var mymedia = new media(file.tointernalurl());                  mymedia.play();             });         });     },     function(err){         console.log('error in requestfilesystem, err.code', err.code);                         } ); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -