nstudio / nativescript-audio

:microphone: NativeScript plugin to record and play audio :musical_note:
Other
150 stars 104 forks source link

Music is resumed when app is suspended after recording video. #107

Closed RoyiNamir closed 6 years ago

RoyiNamir commented 6 years ago

When I set music to play , and the app is minimized , music is still played.

I've managed to fix this by :

 public registerOnSuspend()
        {
            applicationOn(suspendEvent, (args: ApplicationEventData) =>
            {
                if (args.android)
                {
                   this._player.pause();
                }
                else
                {
                    if (args.ios)
                    {
                        this._player.pause();
                    }
                }
            });
        }

.... same for resume ( but with this._player.resume ();)

But Ive noticed that when the app is minimized ( no music - which is OK.) - and if I try to record a video from camera and then stop , suddenly the music is heard again :

image

As you can see , even when the registerOnSuspend function got into action ( meaning app is in suspend mode) , TNSPLAYER got resumed

Again , it happened after app is suspend and after I've opened the camera and recorded a few seconds sec video , and stopeed.