From a1fdf46087de8e1719ec80ac1ca145dacfc8e640 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 11 Jun 2021 14:24:48 +0300 Subject: iOS: Audio remote control, Now Playing info Update the basic Now Playing info about the currently playing music, and respond to remote control commands. Seems to work with MP3 but not other audio formats, probably because those are played via custom decoders. There must be some API for updating the playback status manually. --- src/audio/player.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/audio/player.c') diff --git a/src/audio/player.c b/src/audio/player.c index a2a3955b..94bcd065 100644 --- a/src/audio/player.c +++ b/src/audio/player.c @@ -455,6 +455,8 @@ struct Impl_Player { iAVFAudioPlayer * avfPlayer; /* iOS */ }; +static iPlayer *activePlayer_; + iDefineTypeConstruction(Player) static size_t sampleSize_Player_(const iPlayer *d) { @@ -655,8 +657,14 @@ void deinit_Player(iPlayer *d) { #if defined (iPlatformAppleMobile) if (d->avfPlayer) { delete_AVFAudioPlayer(d->avfPlayer); + if (activePlayer_ == d) { + clearNowPlayingInfo_iOS(); + } } #endif + if (activePlayer_ == d) { + activePlayer_ = NULL; + } } iBool isStarted_Player(const iPlayer *d) { @@ -739,6 +747,7 @@ iBool start_Player(iPlayer *d) { if (d->avfPlayer) { play_AVFAudioPlayer(d->avfPlayer); setNotIdle_Player(d); + activePlayer_ = d; return iTrue; } #endif @@ -756,6 +765,7 @@ iBool start_Player(iPlayer *d) { d->decoder->gain = d->volume; SDL_PauseAudioDevice(d->device, SDL_FALSE); setNotIdle_Player(d); + activePlayer_ = d; return iTrue; } @@ -889,3 +899,7 @@ iString *metadataLabel_Player(const iPlayer *d) { } return meta; } + +iPlayer *active_Player(void) { + return activePlayer_; +} -- cgit v1.2.3