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
  • コード
  • NowPlayingフレームワークについて

    NowPlayingは、ロック画面、コントロールセンター、Dynamic Island、CarPlayなどのシステム上の表示領域とアプリのメディア再生を連係させる、Swiftフレームワークです。このフレームワークのオブザーブ可能なAPIを使用して、再生状態を公開し、コマンドに応答する方法を解説します。リモート再生セッションという新機能を使用すると、外部デバイス上で再生されているメディアをアプリで表示できます。同じシステムサーフェス上ですべての再生コントロールも利用できます。

    関連する章

    • 0:00 - Introduction
    • 1:08 - Media sessions
    • 5:03 - Remote media sessions
    • 10:31 - Media sharing extensions

    リソース

    • Routing media to third-party devices
    • Publishing remote media sessions
    • Publishing media sessions
    • Setting up a remote notification server
      • HDビデオ
      • SDビデオ
  • このビデオを検索
    • 1:57 - Existing PlayerModel implementation

      import Observation
      
      @Observable
      final class PlayerModel {
          let player: SoundPlayer
          var sound: Sound { player.currentSound }
      
          init(player: SoundPlayer) {
              self.player = player
          }
      }
    • 2:06 - Adopt MediaSessionRepresentable

      import NowPlaying
      
      extension PlayerModel: MediaSessionRepresentable {
          var id: String { "ambient-sound-session" }
      
          var content: (any MediaContentRepresentable)? {
              return GenericContent(
                  id: sound.id,
                  title: sound.name,
                  subtitle: sound.description,
                  type: .audio,
                  duration: .live,
                  artwork: Artwork(id: sound.id) { size in
                      let data = try await self.artworkData(size: size)
                      return try ArtworkRepresentation(data: data)
                  }
              )
          }
      
          var playbackSnapshot: MediaPlaybackSnapshot? {
              MediaPlaybackSnapshot(
                  state: player.isPlaying ? .playing() : .paused
              )
          }
      
          var commands: [MediaCommand] {[
              .play { self.player.play() },
              .pause { self.player.pause() },
              .previous { self.player.previous() },
              .next { self.player.next() }
          ]}
      }
    • 4:31 - MediaSession initialization

      import NowPlaying
      
      struct PlayerController {
          let player: SoundPlayer
          let model: PlayerModel
          let session: MediaSession<PlayerModel>
      
          init() {
              self.player = SoundPlayer()
              self.model = PlayerModel(player: player)
              self.session = MediaSession(model)
          }
      }
    • 6:42 - App extension entry point

      import ExtensionFoundation
      import NowPlaying
      
      @main
      final class SampleAppExtension: @MainActor RemoteMediaSessionExtension {
          var configuration: some AppExtensionConfiguration {
              RemoteMediaSessionExtensionConfiguration(extension: self)
          }
      
          var extensionPoint: AppExtensionPoint {
              AppExtensionPoint.Identifier(host: "com.apple.nowplaying", name: "remote-media")
          }
      
          func session(_ state: RemotePlayerState) async throws -> RemotePlayerModel {
              RemotePlayerModel(state: state)
          }
      }
    • 7:23 - Existing RemotePlayerModel implementation

      import Observation
      
      @Observable
      @MainActor
      final class RemotePlayerModel {
          let client: ServerClient
          var state: RemotePlayerState
      
          init(state: RemotePlayerState) {
              self.client = ServerClient(sessionID: state.sessionID)
              self.state = state
          }
      }
    • 7:40 - Adopt RemoteMediaSessionRepresentable in app extension

      import NowPlaying
      
      extension RemotePlayerModel: @MainActor RemoteMediaSessionRepresentable {
          var id: String { state.sessionID }
      
          var content: (any MediaContentRepresentable)? {
              GenericContent(
                  id: state.sound.id,
                  title: state.sound.name,
                  subtitle: state.sound.description,
                  type: .audio,
                  duration: .live,
                  artwork: Artwork(id: state.sound.id) { size in
                      let data = try await self.artworkData(size: size)
                      return try ArtworkRepresentation(data: data)
                  }
              )
          }
      
          var playbackSnapshot: MediaPlaybackSnapshot? {
              MediaPlaybackSnapshot(
                  state: state.isPlaying ? .playing() : .paused
              )
          }
      
          var commands: [MediaCommand] {[
              .play { try await self.client.send(.play) },
              .pause { try await self.client.send(.pause) },
              .previous { try await self.client.send(.previous) },
              .next { try await self.client.send(.next) }
          ]}
      
          var devices: [MediaDevice] {
              state.devices.map { device in
                  MediaDevice(
                      id: device.id,
                      name: device.name,
                      type: .speaker,
                      capabilities: [
                          .absoluteVolume(device.volume) { volume in
                              // send volume change to server
                          }
                      ]
                  )
              }
          }
      
          func update(_ state: RemotePlayerState) {
              self.state = state
          }
      }
    • 0:00 - Introduction
    • Discover the Now Playing system experience, available across all Apple platforms. It allows apps to surface currently playing media info on system surfaces like the Lock Screen, Dynamic Island, and CarPlay.

    • 1:08 - Media sessions
    • Learn how to use the media sessions API to bring audio or video from your app into the system's Now Playing experience by adopting the MediaSessionRepresentable protocol.

    • 5:03 - Remote media sessions
    • Discover how to extend playback control to devices like smart speakers by adopting RemoteMediaSessionRepresentable and utilizing Apple Push Notification service (APNs).

    • 10:31 - Media sharing extensions
    • Find out how Media Sharing Extensions simplify routing media from iPhone to other devices by leveraging the system device picker without needing to embed additional SDKs.

Developer Footer

  • ビデオ
  • WWDC26
  • NowPlayingフレームワークについて
  • メニューを開く メニューを閉じる
    • 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.
    利用規約 プライバシーポリシー 契約とガイドライン