Hey Guys, hope you will be fine, Actually I am facing a problem in playing audio song in ionic I just used StreamingMedia plugin. Everything is right but when I click on the playbutton I get the following error:
See my code below:
.html file:
<ion-content>
<button ion-button full (click)="startAudio1()">Building High Powered High Performance Teams PT1</button>
<button ion-button full (click)="stopAudio1()" color="danger"> Stop Audio </button>
<button ion-button full (click)="startAudio2()">Building High Powered High Performance Teams PT2</button>
<button ion-button full (click)="startAudio3()">Building High Powered High Performance Teams PT3</button>
<button ion-button full (click)="startAudio4()">Mindset of the Million Dollar Earner</button>
<button ion-button full (click)="startAudio5()">Wheel of Prosperity</button>
<button ion-button full (click)="startAudio6()">Never Ending warm lead</button>
<button ion-button full (click)="startAudio7()">Discipline</button>
<button ion-button full (click)="startAudio8()">Double Your Retention Rate</button>
<button ion-button full (click)="startAudio9()">Conference Calls</button>
<button ion-button full (click)="startAudio10()">Think and do What a Millionaire Thinks and Does</button>
<button ion-button full (click)="startAudio11()">Tools PT 1</button>
<button ion-button full (click)="startAudio12()">Tools Pt 2</button>
<button ion-button full (click)="startAudio13()">Opportunity meeting</button>
<button ion-button full (click)="startAudio14()">The Power of Journaling (Triple Your Organization)</button>
</ion-content>
.ts file:
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { ApiProvider } from '../../providers/api/api';
import { StreamingMedia, StreamingAudioOptions } from '@ionic-native/streaming-media/ngx';
@Component({
selector: 'page-enrolled-music',
templateUrl: 'enrolled-music.html',
})
export class EnrolledMusicPage {
values: any;
right: any = [];
constructor(public navCtrl: NavController, public streamingMedia: StreamingMedia, public navParams: NavParams, public api: ApiProvider) {
this.values = this.navParams.get("values");
console.log(this.values);
this.getPosts();
}
getPosts() {
this.api.get('wp/v2/sfwd-lessons/2239').subscribe((data) => {
this.right = data;
this.right = Array.of(this.right);
console.log(this.right);
})
}
startAudio1() {
let options: StreamingAudioOptions = {
successCallback: () => { console.log('Audio played') },
errorCallback: (e) => { console.log('The error is in your code, please check that.') },
initFullscreen: false,
};
this.streamingMedia.playAudio('MyLinkHere', options);
}
stopAudio1() {
this.streamingMedia.stopAudio();
}
}
Please help