View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Videos

Abrir menú Cerrar menú
  • Colecciones
  • Todos los videos
  • Información

Más videos

  • Información
  • Resumen
  • Código
  • Conoce el framework NowPlaying

    Echa un primer vistazo a NowPlaying, un framework de Swift que conecta la reproducción multimedia de tu app con elementos del sistema como la pantalla bloqueada, el Centro de Control, Dynamic Island y CarPlay. Descubre cómo publicar el estado de reproducción y responder a comandos utilizando su API observable. Explora las sesiones de reproducción remota, una nueva capacidad que permite a tu app mostrar el contenido multimedia que se reproduce en dispositivos externos e integrar todos los controles de reproducción en esas mismas interfaces del sistema.

    Capítulos

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

    Recursos

    • Routing media to third-party devices
    • Publishing remote media sessions
    • Publishing media sessions
    • Setting up a remote notification server
      • Video HD
      • Video SD
  • Buscar este video…
    • 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

  • Videos
  • WWDC26
  • Conoce el framework NowPlaying
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • 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 Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines