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
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Create a more responsive media app

    Discover how you can use AVFoundation to keep people focused on your media app's content — not your loading spinner. We'll show you how to support a responsive and fluid interface in your app, all while you create rich audiovisual compositions, load audiovisual assets, and prepare media thumbnails. Find out how you can perform these tasks on your app's main thread while I/O processes in parallel, learn how to get top-notch playback performance when loading data from custom storage, and more.

    To get the most out of this session, we recommend first watching "What's new in AVFoundation” from WWDC21.

    Ressources

    • Creating images from a video asset
    • Loading media data asynchronously
      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC21

    • Meet AsyncSequence
    • Swift concurrency: Update a sample app
    • What’s new in AVFoundation
  • Rechercher dans cette vidéo…
    • 1:41 - Generate a thumbnail

      func thumbnail() async throws -> UIImage {
          let generator = AVAssetImageGenerator(asset: asset)
          generator.requestedTimeToleranceBefore = .zero
          generator.requestedTimeToleranceAfter = CMTime(seconds: 3, preferredTimescale: 600)
          let thumbnail = try await generator.image(at: time).image
          return UIImage(cgImage: thumbnail)
      }
    • 2:56 - Generate a series of thumbnails

      func timelineThumbnails(for times: [CMTime]) async {
          for await result in generator.images(for: times) {
              switch result {
              case .success(requestedTime: let requestedTime, image: let image, actualTime: _):
                  updateThumbnail(for: requestedTime, with: image)
              case .failed(requestedTime: let requestedTime, error: _):
                  updateThumbnail(for: requestedTime, with: placeholder)
              }
          }
      }
    • 3:49 - Generate a series of thumbnails

      func timelineThumbnails(for times: [CMTime]) async {
          for await result in generator.images(for: times) {
              updateThumbnail(for: result.requestedTime, with: (try? result.image) ?? placeholder)
          }
      }
    • 4:40 - AVMutableComposition

      let composition = AVMutableComposition()
      try await composition.insertTimeRange(timeRange, of: asset, at: startTime)
    • 4:57 - AVVideoComposition

      let videoComposition = try await AVVideoComposition .videoComposition(withPropertiesOf: asset)
      
      try await videoComposition.isValid(for: asset, timeRange: range, validationDelegate: delegate)
    • 5:33 - Asset inspection

      asset.loadValuesAsynchronously(forKeys: ["duration", "tracks"]) {
          guard asset.statusOfValue(forKey: "duration", error: &error) == .loaded else { ... }
          guard asset.statusOfValue(forKey: "tracks", error: &error) == .loaded else { ... }
          myFunction(thatUses: asset.duration, and: asset.tracks)
      }
      
      let (duration, tracks) = try await asset.load(.duration, .tracks)
      myFunction(thatUses: duration, and: tracks)
    • 7:06 - Synchronously insert track segments into a composition

      // videoTrack1: AVAssetTrack, videoTrack2: AVAssetTrack
      
      // Create a composition and add an empty track
      let composition = AVMutableComposition()
      guard let compositionTrack = composition
          .addMutableTrack(withMediaType: .video,
                           preferredTrackID: 1) else { return }
      
      // Append the first 5 seconds of track 1
      try compositionTrack
          .insertTimeRange(firstFiveSeconds,
                           of: videoTrack1, at: .zero)
      
      // Append the first 5 seconds of track 2
      try compositionTrack
          .insertTimeRange(firstFiveSeconds,
                           of: videoTrack2, at: fiveSeconds)
      myFunction(thatUses: composition.duration,
                 and: composition.tracks)

Developer Footer

  • Vidéos
  • WWDC22
  • Create a more responsive media app
  • 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