Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ player.$currentAVPlayer // active AVPlayer, re-emitted on every reload (MPNowPl
player.audioTracks // [TrackInfo]
player.selectAudioTrack(index: trackID)

// tvOS info panel / Now Playing
// Info panel / Now Playing (iOS / tvOS)
player.setExternalMetadata([
AVMetadataItem(/* title, artwork, etc. */)
])
Expand Down
10 changes: 6 additions & 4 deletions Sources/AetherEngine/Native/NativeAVPlayerHost.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
import AVFoundation
import AVKit
import Combine

/// `AVPlayer` + `AVPlayerLayer` wrapper owned by AetherEngine. Drives
Expand Down Expand Up @@ -143,9 +144,10 @@ final class NativeAVPlayerHost {
// load (e.g. system Now Playing title + artwork). Setting it
// BEFORE AVPlayer.replaceCurrentItem-equivalent is the documented
// safe order; doing it after the asset has started loading races
// with AVPlayer's internal track-load. tvOS only; AVPlayerItem.externalMetadata
// is unavailable on iOS / macOS.
#if os(tvOS)
// with AVPlayer's internal track-load. `AVPlayerItem.externalMetadata`
// is unavailable on macOS — macOS hosts must write
// `MPNowPlayingInfoCenter` directly.
#if !os(macOS)
if !pendingExternalMetadata.isEmpty {
item.externalMetadata = pendingExternalMetadata
}
Expand Down Expand Up @@ -452,7 +454,7 @@ final class NativeAVPlayerHost {
/// next item created by `load(url:startPosition:)`.
func setExternalMetadata(_ items: [AVMetadataItem]) {
pendingExternalMetadata = items
#if os(tvOS)
#if !os(macOS)
playerItem?.externalMetadata = items
#endif
}
Expand Down