#32 - Building a Video and Audio Playback App
With just a few lines of code, your app can play a video or audio
Hey iOS developer! 👋
After taking a few months off, I’m slowly getting back to publishing new issues of the Curated iOS newsletter. If you’ve subscribed recently - welcome! 🎉
In this newsletter, I share iOS development articles, with each issue dedicated to a specific topic. This time, I’m focusing on something very specific: building a video and audio playback app.
How to play videos from an URL with AVPlayer and SwiftUI
Let's kick things off with the very basics - simple AVPlayer implementation in SwiftUI. AVPlayer is Apple’s AVFoundation class to playback videos, audio and HLS streams. Desilio Neto article can help you get started with exploring the AVPlayer’s possibilities in the iOS app.
Read on Medium
How to use VideoPlayer in SwiftUI
This article by Gokhan Mutlu also covers the basic implementation of AVPlayer in SwiftUI. However, it goes a step further by introducing an interesting idea - using RealityKit to playback the video in an immersive environment.
Read on Medium
Mastering SwiftUI and AVPlayer Integration: A Complete Guide to Timecodes and Advanced Playback Control
Here’s another AVPlayer implementation guide - but in this article, the author shows how to build custom player controls from scratch. Additionally, Aitolkun Anarbekova explains how to use UIViewControllerRepresentable
protocol to bridge UIKit's AVPlayerViewController
with SwiftUI.
Read on Medium
How to lower background music volume when playing audio in Swift
If your app needs to play a short sound while other audio is playing in the background, you can use AVAudioSession
to temporarily reduce background volume. This article explains how to activate your app’s audio session and deactivate it preperly. A great example of this use case is workout app that plays short sounds.
Read on Medium
Rock Your App’s Playback Experience with Now Playing in iOS
The Apple ecosystem offers media playback controls on the Lock Screen and Control Center through a feature called Now Playing. When properly configured in the app, it allows users to pause/play, skip, adjust the volume, and display basic media metadata such as the title and artwork. This article by Mayank Kumar Gupta provides a detailed guide on how to integrate Now Playing into your app.
Read on Medium
Implementing Background play & Picture-in-Picture in SwiftUI: Building a Video Streaming App with AVPlayer and SwiftUI
With the Picture-in-Picture (PiP) system feature, users can continue watching a video from your app while use other apps. Implementing it is as simple as setting the allowsPictureInPicturePlayback
flag on the AVPlayer, assuming it’s properly implemented. Khondakar Afridi explains how to set up background playback along with the PiP in SwiftUI.
Read on Medium
Setting up SharePlay on an iOS app
Another interesting iOS feature is SharePlay - it allows multiple people to watch a movie, listen to music, or play a game together on a FaceTime call or Messages conversation. Here is Pol Piella’s step-by-step guide to build SharePlay experience into your app, from enabling capabilities to adding the SharePlay extension.
Read on Pol Piella blog
AVFoundation: Create Audio-Video Compositions
If basic audio and video play back isn’t enough, take it further by re-arranging user’s audio and video assets using AVFoundation
’s Audio-Video Compositions. Anubhav Rawat explains how to use AVMutableComposition
to create a new media asset and export it to the file.
Read on Medium
If you found this Curated iOS issue useful, I’d be happy if you:
Hit the Like button.
Subscribe, if you haven’t already!
Connect with me on LinkedIn.
Until next time!
Artjoms