Hi,
I’m trying to play simple .mp3 file on tap of the button but can’t figure out why it isn’t working with ionic2.
I place my media file under ionic2root/www/media/alarm.mp3
Imports
import {Component,NgZone,Injectable} from '@angular/core';
import {NavController, Alert, NavParams, Platform} from 'ionic-angular';
import {StatusBar,MediaPlugin,BackgroundMode} from 'ionic-native';
export class UserPage {
static get parameters() {
return [[AuthService],[NavController],[NgZone]];
}
constructor(authservice, navcontroller, ngzone, platform) {
this.service = authservice;
this.nav = navcontroller;
this.distance = 0;
this.time = new Date();
this.ngzone=ngzone;
this.platform = platform;
this.theft = 0;
this.myModel = false;
//setInterval(() => this.time = new Date(), 1000);
}
playFile(){
var file = new Media("media/alarm.mp3",// success callback
function () {
alert("success");
},
// error callback
function (e) {
alert("Error getting amp=" + e.code);
});
file.play();
}
}
Questions
- i tried using ionic-native but no luck?
- Is my file path is right?
- Wan’t fill confident with ionic-native!
Ionic native gives following error
npm install ionic-native --save
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.12
npm WARN ionic2-ble-demo@ No repository field.
npm WARN ionic2-ble-demo@ No license field.
Please advise.