Cordova Media Plugin | No Reference


#1

I’m loosing hope. Please help me from having to use Xamarin :wink:

I’m trying to use the cordova media plugin with Ionic 2, but for the life of me, I can’t figure out how to get a reference to the Media object for that plugin. Every piece of advice I have gotten for this problem informs me that you don’t have to do anything special to reference plugins (no imports or anything).

Given that advice, I should be able to just use something like:
let myMedia = new Media()
anywhere in my app. But it simply does not exist. I’ve tried window.Media. Still nothing. I have no idea how to reference this plugin’s object.

I’m on the latest version of Ionic 2 beta with TypeScript. I’ve un-installed and re-installed the plugin to no avail. Below is the very brief snippet of code I’m trying to set up:

export class SoundService {
    constructor() {
        let media = new Media(); // this does not exist.
    }
}

Thanks


#2

Using declare let Media: any; worked for me.

As mentioned here


#3

my problem is similar, i dont a instancia the mediaplugin, does not recognize methods.

my code is simple

1º import
import { MediaPlugin } from ‘ionic-native’;
2º create intancia and call play
let media = new MediaPlugin(“http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3”);
media.play();

error

EXCEPTION: Cannot read property ‘play’ of undefined


#4

Hello everyone,
how can I specify an MP3 remote link.

I tried this, but it does not work:

media: MediaPlugin = new MediaPlugin (‘http://www.example.com/audio/mp3/example.mp3’);

thank you


#5

I’m getting this still on RC4. Any update to a fix?