extension
NewiOS
MusicVideo
NewiOSextension MusicVideo : PickableMusicItemDeclaration
extension MusicVideo : PickableMusicItem {
}What's New / Media, Audio & Capture
MusicKit gives apps access to the Apple Music catalog and a user's library, including catalog requests, playback, and music item models like Song, Track, and MusicVideo.
The 27 SDK adds 6 APIs with no deprecations or removals. A new PickableMusicItem protocol is adopted by music item types including Song, Track, and MusicVideo. MusicCatalogResourceResponse gains an item property, and there is a new View entry point for music item selection.
MusicVideoextension MusicVideo : PickableMusicItemextension MusicVideo : PickableMusicItem {
}PickableMusicItempublic protocol PickableMusicItem : MusicItem, Decodable, Encodable, HashableA protocol for the MusicKit item type that can be selected in the music picker.
public protocol PickableMusicItem : MusicItem, Decodable, Encodable, Hashable {
}Songextension Song : PickableMusicItemextension Song : PickableMusicItem {
}Trackextension Track : PickableMusicItemextension Track : PickableMusicItem {
}Viewextension Viewextension View {
/// Presents a music picker to select items from the Apple Music catalog and the user’s music library.
///
/// - Parameters:
/// - isPresented: The binding to whether the music picker should be shown.
/// - title: The title to be shown in the navigation bar.
/// - selection: The selected music item.
///
/// Example:
/// ```swift
/// struct MusicPickerButton: View {
/// @State private var isShowingMusicPicker = false
/// @State private var selectedSong: Song?
///
/// var body: some View {
/// Button("Pick a song") {
/// isShowingMusicPicker = true
/// }
/// .musicPicker(isPresented: $isShowingMusicPicker, selection: $selectedSong)
/// }
/// }
/// ```
@MainActor @preconcurrency public func musicPicker<Selection>(isPresented: Binding<Bool>, title: Text? = nil, selection: Binding<Selection?>) -> some View where Selection : PickableMusicItem
/// Presents a music picker to select items from the Apple Music catalog and the user’s music library.
///
/// - Parameters:
/// - isPresented: The binding to whether the music picker should be shown.
/// - title: The title to be shown in the navigation bar.
/// - selection: The selected music items.
///
/// Example:
/// ```swift
/// struct MusicPickerButton: View {
/// @State private var isShowingMusicPicker = false
/// @State private var selectedSongs: [Song] = []
///
///
/// var body: some View {
/// Button("Pick one or more songs") {
/// isShowingMusicPicker = true
/// }
/// .musicPicker(isPresented: $isShowingMusicPicker, selection: $selectedSongs)
/// .onChange(of: selectedSongs) { oldValue, newValue in
/// let delta = newValue.count - oldValue.count
/// print("You selected \(delta) new tracks!")
/// }
/// }
/// }
/// ```
@MainActor @preconcurrency public func musicPicker<Selection>(isPresented: Binding<Bool>, title: Text? = nil, selection: Binding<[Selection]>) -> some View where Selection : PickableMusicItem
/// Presents a music picker to select items from the Apple Music catalog and the user’s music library.
///
/// - Parameters:
/// - isPresented: The binding to whether the music picker should be shown.
/// - title: The title to be shown in the navigation bar.
/// - selection: The selected music items.
///
/// Example:
/// ```swift
/// struct MusicPickerButton: View {
/// @State private var isShowingMusicPicker = false
/// @State private var selectedSongs: MusicItemCollection<Song> = []
/// private var title = "Add to Playlist"
///
/// var body: some View {
/// Button("Pick one or more songs") {
/// isShowingMusicPicker = true
/// }
/// .musicPicker(
/// isPresented: $isShowingMusicPicker,
/// title: Text(title),
/// selection: $selectedSongs
/// )
/// .onChange(of: selectedSongs) { oldValue, newValue in
/// let delta = newValue.count - oldValue.countTruncated.
MusicCatalogResourceResponse.itempublic func item(for id: MusicItemID) -> MusicItemType?Returns the item in this response that corresponds to the given identifier.
No APIs match your filter.