ionic-audio icon indicating copy to clipboard operation
ionic-audio copied to clipboard

Listen for play event

Open betatools opened this issue 7 years ago • 4 comments

Hello

Is it possible for me to listen for the play event? I'm using Ionic 3

betatools avatar Aug 27 '17 14:08 betatools

There's no play event so far, only the onFinish event. But it may be a good idea to add it. What do you need it for?

arielfaur avatar Aug 29 '17 18:08 arielfaur

Hi

Thx for getting back to me. I "need" it for analytics/statistics.

I actually found a way to make it work, but perhaps your event solution would be more elegant.

In the view

<audio-track #track [track]="singleTrack" (onFinish)="onTrackFinished($event)">
     <h1 text-center>{{track.title}}</h1>
     <ion-item no-padding no-lines [audioTrack]="track">
         <ion-thumbnail item-left (click)="trackEvent()">
             <audio-track-play light [audioTrack]="track">
                <ion-spinner></ion-spinner>
             </audio-track-play>
         </ion-thumbnail>
     </ion-item>
</audio-track>

In the component

trackEvent()
{
   let track = this._audioProvider.tracks[this._audioProvider.current];

   if ( track )
   {
            // Doing analytics
   }
}

betatools avatar Aug 29 '17 19:08 betatools

@arielfaur We need it for the same purpose.

@betatools I know it's too old but how did you manage to do this?

Abhi0725 avatar Apr 16 '19 11:04 Abhi0725

Hi @Abhi0725 @betatools This repo is not maintained anymore, I don't have time to commit to this, sorry!

arielfaur avatar Apr 16 '19 12:04 arielfaur