How can I change the the button icon from "play" to "pause" in my code

I have a page to play the online music using the Audio object.
My question is how can I change the the button icon from “play” to “pause” after it was clicked in my code ?

<button ion-button icon-only round (click)="playAudio($event, poem)"    >
  <ion-icon name="play" ></ion-icon  >
</button  >

many thanks,

bind your ion icon to a variable like this:

<ion-icon [name]="someVar">

Then switch someVar from play to the pause icon :slight_smile:

1 Like

Could someone please explain me how to change somevar to play or pause.

Actually I have two buttons:

<button ion-button icon-only round (click)="startAudio()">
  			<ion-icon [name]="someVar"></ion-icon  >
		<button ion-button  (click)="stopAudio()" color="danger">
			<ion-icon name="pause" id ="pause"></ion-icon>

I have a function for each button.

  startAudio() {
  	let options: StreamingAudioOptions = {
      successCallback: () => { console.log('Finished Audio') },
      errorCallback: (e) => { console.log('Error: ', e) },
      initFullscreen: false // iOS only!
    this.streamingMedia.playAudio('http://myurl/music.mp3', options);

  stopAudio() {

How can I do that, please