Hello. I’m new to App developement and ionic. I’ve been playing around with creating a simple media player using the cordova media plugin and ionic v2. The effect I would like to achieve is for my local mp3 to play from the start of the track and resume play after a pause using the same button, but when I run the code below, the play button always plays from the beginning of the track. The pause button works fine. Any ideas what I might be doing wrong?
Typescript code:
export class HomePage {
file;
constructor(public navCtrl: NavController) {
}
mediaplay(){
this.file = new MediaPlugin('assets/audio/sample1.mp3', (status) => {});
this.file.play();
}
mediapause(){
this.file.pause();
}
}
Relevant html code:
<ion-row>
<ion-col width-20>
<button ion-button (click)="mediaplay()">
<ion-icon name='md-play'></ion-icon>
</button>
</ion-col>
<ion-col width-20>
<button ion-button (click)="mediapause()">
<ion-icon name='md-pause'></ion-icon>
</button>
</ion-col>
</ion-row>