View in English

  • Apple Developer
    • 今すぐ始める

    「今すぐ始める」を詳しく見る

    • 概要
    • 学ぶ
    • Apple Developer Program

    最新情報

    • 最新ニュース
    • Hello Developer
    • プラットフォーム

    プラットフォームを詳しく見る

    • Appleプラットフォーム
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    特集

    • デザイン
    • 配信
    • ゲーム
    • アクセサリ
    • Web
    • Home
    • CarPlay
    • テクノロジー

    テクノロジーを詳しく見る

    • 概要
    • Xcode
    • Swift
    • SwiftUI

    特集

    • アクセシビリティ
    • App Intent
    • Apple Intelligence
    • ゲーム
    • 機械学習とAI
    • セキュリティ
    • Xcode Cloud
    • コミュニティ

    コミュニティを詳しく見る

    • 概要
    • 「Appleに相談」イベント
    • コミュニティによるイベント
    • デベロッパフォーラム
    • オープンソース

    特集

    • WWDC
    • Swift Student Challenge
    • デベロッパストーリー
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Center
    • ドキュメント

    ドキュメントを詳しく見る

    • ドキュメントライブラリ
    • テクノロジー概要
    • サンプルコード
    • ヒューマンインターフェイスガイドライン
    • ビデオ

    リリースノート

    • 注目のアップデート
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • ダウンロード

    ダウンロードを詳しく見る

    • すべてのダウンロード
    • オペレーティングシステム
    • アプリ
    • デザインリソース

    特集

    • Xcode
    • TestFlight
    • フォント
    • SF Symbols
    • Icon Composer
    • サポート

    サポートを詳しく見る

    • 概要
    • ヘルプガイド
    • デベロッパフォーラム
    • フィードバックアシスタント
    • お問い合わせ

    特集

    • アカウントヘルプ
    • App Reviewガイドライン
    • App Store Connectヘルプ
    • 近日導入予定の要件
    • 契約およびガイドライン
    • システムステータス
  • クイックリンク

    • イベント
    • ニュース
    • Forum
    • サンプルコード
    • ビデオ
 

ビデオ

メニューを開く メニューを閉じる
  • コレクション
  • すべてのビデオ
  • 利用方法

その他のビデオ

  • 概要
  • Summary
  • コード
  • アプリへのMusicKitの統合

    MusicKitを使って、Apple Musicの機能をアプリに組み込みましょう。このセッションでは、認可、サブスクリプション状況の確認、楽曲の選択、再生のコントロール、複数のストアフロント間での楽曲共有といったトピックを取り上げます。Apple Musicカタログや個人用ライブラリを閲覧できる機能を、新しいミュージックピッカーを使ってユーザーに提供する方法を解説します。また、SystemMusicPlayerとApplicationMusicPlayerの違いや、再生の状態をオブザーブする方法も紹介します。

    関連する章

    • 0:00 - Introduction
    • 2:11 - Project setup and authorization
    • 7:10 - Music items and music picker
    • 10:54 - Music players and playback
    • 16:26 - Catalog requests
    • 20:11 - Next steps

    リソース

    • Integrating MusicKit into your app
    • Apple Services Performance Partner Program
    • MusicKit
      • HDビデオ
      • SDビデオ

    関連ビデオ

    WWDC23

    • SwiftUIにおけるObservationの説明

    WWDC22

    • Apple Music APIとMusicKitの紹介
    • MusicKitでコンテンツをさらに見つける
  • このビデオを検索
    • 4:47 - Presents the Apple Music subscription offer

      @State var showSubscriptionOffer = false
      
      let options = MusicSubscriptionOffer.Options(
          messageIdentifier: .playMusic
      )
      
      @ViewBuilder
      var musicSubsriptionButton: some View {
          Button("Subscribe to Apple Music", systemImage: "music.note") {
              showSubscriptionOffer = true
          }
          .musicSubscriptionOffer(isPresented: $showSubscriptionOffer, options: options)
      }
    • 5:59 - Adds subscription button to main view

      @State var subscription: MusicSubscription?
      
      var body: some View {
        	VStack {
              // ...
              if let subscription, subscription.canBecomeSubscriber {
                  musicSubscriptionButton
              }
          }
          .task(id: isAuthorized) {
      	      self.subscription = try? await MusicSubscription.current
              for await subscription in MusicSubscription.subscriptionUpdates {
                  self.subscription = subscription
              }
          }
      }
    • 8:48 - Add .musicPicker() modifier

      @State var showMusicPicker = false
      @State var selectedSong: Song? = nil
      
      @ViewBuilder
      var musicPickerButton: some View {
          Button("Pick some Music", systemImage: "music.note.list") {
              showMusicPicker = true
          }
          .musicPicker(isPresented: $showMusicPicker, selection: $selectedSong)
      }
      
      var body: some View {
          VStack {
              if let subscription, subscription.canBecomeSubscriber {
                  musicSubscriptionButton
              }
              musicPickerButton
          }
      }
    • 14:49 - Artwork

      @State var queue = ApplicationMusicPlayer.shared.queue
      
      var body: some View {
          VStack {
              if let artwork = queue.currentEntry?.artwork {
                  ArtworkImage(artwork, width: 200, height: 200)
              } else {
                  // Placeholder artwork
                  RoundedRectangle(cornerRadius: 16)
                      .fill(.quaternary)
                      .frame(width: 200, height: 200)
              }
          }
      }
    • 15:06 - Current entry info

      @State var queue = ApplicationMusicPlayer.shared.queue
      
      var body: some View {
          VStack {
              // ...
              if let currentSong = queue.currentEntry {
                  Text(currentSong.title)
                      .font(.title3.bold())
                    
                  if let subtitle = currentSong.subtitle {
                      Text(subtitle)
                          .font(.subheadline)
                          .foregroundStyle(.secondary)
                  }
              }
          }
      }
    • 15:14 - Playback controls (play, pause)

      let player = ApplicationMusicPlayer.shared
      @State var state = ApplicationMusicPlayer.shared.state
      
      var isPlaying: Bool {
          state.playbackStatus == .playing
      }
      
      var playPause: some View {
          Button (
              isPlaying ? "Pause": "Play",
              systemImage: isplaying ? "pause.fill" : "play.fill"
          ) {
              if isPlaying {
                  player.pause()
              } else {
                  Task {
                      try await player.play()
                  }
              }
          }
      }
    • 15:38 - Playback controls (next, previous)

      let player = ApplicationMusicPlayer.shared
      
      var controls: some View {
          HStack {
              Button("Back", systemImage: "backward.fill") {
                  Task {
                      try await player.skipToPreviousEntry()
                  }
              }
              // ...
              Button("Next", systemImage: "forward.fill") {
                  Task {
                      try await player.skipToNextEntry()
                  }
              }
          }
      }
    • 18:58 - Music catalog resource request

      func fetchSongs(songIDs: [MusicItemID]) async throws -> (featured: Song?, other: [Song]) {
          var request = MusicCatalogResourceRequest‹Song>(matching: \.id, memberOf: songIDs)
          request.options = [.findEquivalents]
          
          let response = try await request.response()
          
          let featuredSongID = songIDs[0]
          let featuredSong = response.item(for: featuredSongID)
          
          let others: [Song] = songIDs[1...].compactMap { songID in
              return response.item(for: songID)
          }
          
          return (featuredSong, others)
      }
    • 0:00 - Introduction
    • An introduction to MusicKit and an overview of how to build a music-enhanced workout app using Swift concurrency and SwiftUI.

    • 2:11 - Project setup and authorization
    • Learn how to configure your Xcode project with the necessary capabilities, request music library authorization, and present Apple Music subscription offers to users.

    • 7:10 - Music items and music picker
    • Explore the properties and relationships of MusicKit music items, and use the music picker view modifier to let users browse and select songs from the Apple Music catalog or their own library.

    • 10:54 - Music players and playback
    • Dive into using SystemMusicPlayer and ApplicationMusicPlayer. Discover how to set up playback queues, observe playback state, and build UI controls for playback in SwiftUI.

    • 16:26 - Catalog requests
    • Use structured catalog requests like MusicCatalogResourceRequest to fetch curated Apple Music content, and learn how to handle localization and content equivalency.

    • 20:11 - Next steps
    • A quick recap of MusicKit capabilities and pointers to related sessions for further learning.

Developer Footer

  • ビデオ
  • WWDC26
  • アプリへのMusicKitの統合
  • メニューを開く メニューを閉じる
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • SF Symbols
    メニューを開く メニューを閉じる
    • アクセシビリティ
    • アクセサリ
    • Apple Intelligence
    • App Extension
    • App Store
    • オーディオとビデオ(英語)
    • 拡張現実
    • デザイン
    • 配信
    • 教育
    • フォント(英語)
    • ゲーム
    • ヘルスケアとフィットネス
    • アプリ内課金
    • ローカリゼーション
    • マップと位置情報
    • 機械学習とAI
    • オープンソース(英語)
    • セキュリティ
    • SafariとWeb(英語)
    メニューを開く メニューを閉じる
    • 英語ドキュメント(完全版)
    • 日本語ドキュメント(一部トピック)
    • チュートリアル
    • ダウンロード
    • フォーラム(英語)
    • ビデオ
    Open Menu Close Menu
    • サポートドキュメント
    • お問い合わせ
    • バグ報告
    • システム状況(英語)
    メニューを開く メニューを閉じる
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles(英語)
    • フィードバックアシスタント
    メニューを開く メニューを閉じる
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program(英語)
    • Mini Apps Partner Program
    • News Partner Program(英語)
    • Video Partner Program(英語)
    • セキュリティ報奨金プログラム(英語)
    • Security Research Device Program(英語)
    Open Menu Close Menu
    • Appleに相談
    • Apple Developer Center
    • App Store Awards(英語)
    • Apple Design Awards
    • Apple Developer Academy(英語)
    • WWDC
    最新ニュースを読む。
    Apple Developerアプリを入手する。
    Copyright © 2026 Apple Inc. All rights reserved.
    利用規約 プライバシーポリシー 契約とガイドライン