AVPlayer-SwiftUI

repository·master·Indexed 42 days ago

https://github.com/chrismash/avplayer-swiftui

A collection of patterns and implementations for integrating AVPlayer into SwiftUI applications. It provides guidance on using the native iOS 14+ VideoPlayer view as well as building custom UI controls for video and audio playback.

Tokens
286
Snippets
0
Records
2
Agent score
4%

What's inside AVPlayer-SwiftUI

  1. Overview of AVPlayer-SwiftUI

    master

    AVPlayer-SwiftUI is a collection of implementations and patterns for integrating AVPlayer with SwiftUI. It provides two main approaches:

    1. Custom UI Implementation: A series of patterns (Parts 1-4) for building highly customized video and audio player controls. This is useful if you need a UI that differs significantly from the system default.
    2. Native SwiftUI VideoPlayer: Leveraging the built-in VideoPlayer view introduced in iOS 14 for standard, low-effort video playback.

    The repository demonstrates how to handle player observation, custom control overlays, and switching between audio and video playback modes.

  2. When to use custom controls vs. SwiftUI's VideoPlayer

    master

    Choosing between a custom implementation and the native SwiftUI VideoPlayer depends on your UI requirements:

    • Use SwiftUI's VideoPlayer: If you are satisfied with the default system controls provided by Apple. It is the simplest way to achieve video playback with minimal code.
    • Use Custom Implementation (Parts 1-4): If you need a custom user interface. The repository provides patterns for building custom VideoView and AudioView structures to manage player state and controls manually.