Skip to content

Commit

Permalink
Merge pull request #366 from THEOplayer/feature/ios-artist-and-album-…
Browse files Browse the repository at this point in the history
…metadata

Added support on iOS for 'album' and 'artist' in the nowPlayingInfo
  • Loading branch information
wvanhaevre authored Aug 14, 2024
2 parents 92f2d71 + a608bc3 commit 8bb33a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Fixed an issue on Android where the notification background would be displayed in low resolution on recent Android versions.

### Added

- Added support on iOS for 'album' and 'artist' in the nowPlayingInfo.

## [7.8.0] - 24-08-09

### Added
Expand Down
14 changes: 14 additions & 0 deletions ios/backgroundAudio/THEOplayerRCTNowPlayingManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class THEOplayerRCTNowPlayingManager {
self.updatePlaybackState()
self.nowPlayingInfo = [String : Any]()
self.updateTitle(metadata.title)
self.updateArtist(metadata.metadataKeys?["artist"] as? String)
self.updateAlbum(metadata.metadataKeys?["album"] as? String)
self.updateSubtitle(metadata.metadataKeys?["subtitle"] as? String)
self.updateDuration(player.duration)
self.updateMediaType() // video
Expand Down Expand Up @@ -106,6 +108,18 @@ class THEOplayerRCTNowPlayingManager {
}
}

private func updateArtist(_ metadataArtist: String?) {
if let artist = metadataArtist {
self.nowPlayingInfo[MPMediaItemPropertyArtist] = artist
}
}

private func updateAlbum(_ metadataAlbum: String?) {
if let album = metadataAlbum {
self.nowPlayingInfo[MPMediaItemPropertyAlbumTitle] = album
}
}

private func updateSubtitle(_ metadataSubtitle: String?) {
if let subtitle = metadataSubtitle {
self.nowPlayingInfo[MPMediaItemPropertyArtist] = subtitle
Expand Down

0 comments on commit 8bb33a4

Please sign in to comment.