@GGopal wrote:
All, I am new to Ionic. Starting my first app. I am using my Windows PC to build using Visual Studio as my editor. I want to do is accept an input from user, and if they enter a number greater than 10 I want to send a beep or some kind of an audible noise. I am able to show an alert, but I want to do is audible noise which
should work in the browser and as an app as well.I have seen sample for native-audio and tried that. When I add the public constructor my app does not work. in my screen I get error stating it is being used as a function but cannot use. The sample here works without any errors now. But no beep noise? can some one help please. Code below. When I click on the button nothing happens NO BEEP.
Here is my home.page.ts
import { Component } from ‘@angular/core’;
import { NativeAudio } from ‘@ionic-native/native-audio’;
import { NavController, Platform } from “@ionic/angular”;@Component({
selector: ‘app-home’,
templateUrl: ‘home.page.html’,
styleUrls: [‘home.page.scss’],
})
export class HomePage {
constructor(public navCtrl: NavController,public platform: Platform,private nativeAudio: NativeAudio) {
this.platform.ready().then(() => {
this.nativeAudio.preloadSimple(‘uniqueId1’, ‘assets/audio/beep.mp3’).then((success)=>{
console.log(“success”);
},(error)=>{
console.log(error);
});
});
}play(){
this.nativeAudio.play(‘uniqueId1’).then((success)=>{
console.log(“success playing”);
},(error)=>{
console.log(error);
});
}}
Here is my home.page.html
Ionic Blank
The world is your oyster.If you get lost, the docs will be your guide.
<button ion-button (click)=“play()”>play
Posts: 1
Participants: 1