I'm attempting to create a simple media player with Ionic 3 and the MediaObject from Ionic-Native is giving me some trouble.
app.component.ts
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { MediaPlugin, MediaObject } from '@ionic-native/media';
import { HomePage } from '../pages/home/home';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = HomePage;
file:MediaObject = undefined;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private media: MediaPlugin) {
const onStatusUpdate = (status) => console.log(status);
media.create('./path/to/file.mp3', onStatusUpdate)
.then((file: MediaObject) => {``
this.file = file;
});
}
play() {
this.file.play();
}
}
My issue is that when I serve the project I get "Property 'then' does not exist on type 'MediaObject'"
From my understanding media.create SHOULD be returning a MediaObject promise that once resolved will allow me to use the MediaObject.
Any insight is appreciated.
the doc says create
Returns: MediaObject
not a promise