AVPlayer video playback integration in iOS app

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
AVPlayer video playback integration in iOS app
Medium
~2-3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Integrating AVPlayer for Video Playback in iOS Application

AVPlayer is a native iOS player with support for HLS, MPEG-4, progressive download, AirPlay, Picture in Picture and subtitles. Before using third-party players (VLCKit, IJKPlayer), it's worth understanding what AVPlayer can do — in most cases it's sufficient.

Basic Integration

AVPlayer doesn't display video by itself — it manages playback. For display you need AVPlayerLayer, embedded in UIView.layer, or AVPlayerViewController from AVKit — a ready-made controller with system controls.

let player = AVPlayer(url: videoURL)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = containerView.bounds
playerLayer.videoGravity = .resizeAspect
containerView.layer.addSublayer(playerLayer)
player.play()

For SwiftUI — VideoPlayer from AVKit, a wrapper over AVPlayerViewController.

Where Problems Appear

Buffering and state. player.currentItem?.status doesn't reflect real-time readiness for playback. The correct approach — KVO on player.currentItem and timeControlStatus:

player.publisher(for: \.timeControlStatus)
    .receive(on: DispatchQueue.main)
    .sink { status in
        switch status {
        case .playing: hideLoader()
        case .waitingToPlayAtSpecifiedRate: showLoader()
        case .paused: break
        }
    }

HLS and quality. For HLS (m3u8) AVPlayer automatically selects stream by bandwidth. You can manage selection via AVPlayerItem.preferredPeakBitRate (limitation) or AVPlayerItem.preferredMaximumResolution. Manual quality selection — through AVMediaSelectionGroup with AVAssetVariant.

Background playback. Audio stream when app goes to background requires: enabled capability "Background Modes → Audio, AirPlay" in Xcode and AVAudioSession.shared.setCategory(.playback) before player.play(). Without setCategory audio is cut off immediately when app goes to background.

Picture in Picture. AVPictureInPictureController requires AVPlayerLayer or AVPlayerViewController. Add AVPictureInPictureControllerDelegate, in Info.plistUIBackgroundModes: audio. Enable pictureInPictureController.startPictureInPicture() on button click. PiP works only on physical devices, not in simulator.

Custom Controls

If AVPlayerViewController doesn't suit the design, build a custom player on top of AVPlayer + AVPlayerLayer:

  • Progress bar: player.addPeriodicTimeObserver(forInterval: CMTime(seconds: 0.5), queue: .main) to update position
  • Seeking: player.seek(to: CMTime(seconds: targetSeconds, preferredTimescale: 600), toleranceBefore: .zero, toleranceAfter: .zero)toleranceBefore/After: .zero gives exact position but is slower
  • Subtitles: AVMediaCharacteristic.legible + AVPlayerItem.select(_:in:) for switching tracks

What's Included in the Work

  • Integrating AVPlayer with AVPlayerLayer or AVPlayerViewController
  • Custom UI controls (play/pause, seek bar, fullscreen)
  • Background playback and AirPlay
  • Picture in Picture (if iOS 14+ required)
  • HLS with quality selection capability
  • Network and buffering error handling with retry logic

Timeline

Basic player with system controls: half a day. Fully custom player with subtitles, PiP and HLS quality selector: 2–3 days. Cost is calculated individually.