diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-06-11 14:24:48 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-06-11 14:24:48 +0300 |
commit | a1fdf46087de8e1719ec80ac1ca145dacfc8e640 (patch) | |
tree | 9abfbe628947a02f54dcf68385b3d66ff4470d42 /src/audio | |
parent | 31f7eafd9c6897cdf0ee7d6eeaade9dcc65cb006 (diff) |
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.
Diffstat (limited to 'src/audio')
-rw-r--r-- | src/audio/player.c | 14 | ||||
-rw-r--r-- | src/audio/player.h | 2 |
2 files changed, 16 insertions, 0 deletions
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 { | |||
455 | iAVFAudioPlayer * avfPlayer; /* iOS */ | 455 | iAVFAudioPlayer * avfPlayer; /* iOS */ |
456 | }; | 456 | }; |
457 | 457 | ||
458 | static iPlayer *activePlayer_; | ||
459 | |||
458 | iDefineTypeConstruction(Player) | 460 | iDefineTypeConstruction(Player) |
459 | 461 | ||
460 | static size_t sampleSize_Player_(const iPlayer *d) { | 462 | static size_t sampleSize_Player_(const iPlayer *d) { |
@@ -655,8 +657,14 @@ void deinit_Player(iPlayer *d) { | |||
655 | #if defined (iPlatformAppleMobile) | 657 | #if defined (iPlatformAppleMobile) |
656 | if (d->avfPlayer) { | 658 | if (d->avfPlayer) { |
657 | delete_AVFAudioPlayer(d->avfPlayer); | 659 | delete_AVFAudioPlayer(d->avfPlayer); |
660 | if (activePlayer_ == d) { | ||
661 | clearNowPlayingInfo_iOS(); | ||
662 | } | ||
658 | } | 663 | } |
659 | #endif | 664 | #endif |
665 | if (activePlayer_ == d) { | ||
666 | activePlayer_ = NULL; | ||
667 | } | ||
660 | } | 668 | } |
661 | 669 | ||
662 | iBool isStarted_Player(const iPlayer *d) { | 670 | iBool isStarted_Player(const iPlayer *d) { |
@@ -739,6 +747,7 @@ iBool start_Player(iPlayer *d) { | |||
739 | if (d->avfPlayer) { | 747 | if (d->avfPlayer) { |
740 | play_AVFAudioPlayer(d->avfPlayer); | 748 | play_AVFAudioPlayer(d->avfPlayer); |
741 | setNotIdle_Player(d); | 749 | setNotIdle_Player(d); |
750 | activePlayer_ = d; | ||
742 | return iTrue; | 751 | return iTrue; |
743 | } | 752 | } |
744 | #endif | 753 | #endif |
@@ -756,6 +765,7 @@ iBool start_Player(iPlayer *d) { | |||
756 | d->decoder->gain = d->volume; | 765 | d->decoder->gain = d->volume; |
757 | SDL_PauseAudioDevice(d->device, SDL_FALSE); | 766 | SDL_PauseAudioDevice(d->device, SDL_FALSE); |
758 | setNotIdle_Player(d); | 767 | setNotIdle_Player(d); |
768 | activePlayer_ = d; | ||
759 | return iTrue; | 769 | return iTrue; |
760 | } | 770 | } |
761 | 771 | ||
@@ -889,3 +899,7 @@ iString *metadataLabel_Player(const iPlayer *d) { | |||
889 | } | 899 | } |
890 | return meta; | 900 | return meta; |
891 | } | 901 | } |
902 | |||
903 | iPlayer *active_Player(void) { | ||
904 | return activePlayer_; | ||
905 | } | ||
diff --git a/src/audio/player.h b/src/audio/player.h index b131838d..ca307dc4 100644 --- a/src/audio/player.h +++ b/src/audio/player.h | |||
@@ -68,3 +68,5 @@ float streamProgress_Player (const iPlayer *); /* normalized 0...1 */ | |||
68 | 68 | ||
69 | uint32_t idleTimeMs_Player (const iPlayer *); | 69 | uint32_t idleTimeMs_Player (const iPlayer *); |
70 | iString * metadataLabel_Player (const iPlayer *); | 70 | iString * metadataLabel_Player (const iPlayer *); |
71 | |||
72 | iPlayer * active_Player (void); | ||