OVERVIEW

AudioPlayer is a reusable iOS media player component for usage in iOS 8 or later that can be integrated in an application using Objective-C or Swift.

MOTIVATION

When creating an app using the AVFoundation framework, there are a lot of things to be taken care of: resource management and more precise player items interchange, player flow for play and pause functionality and constantly checking the player’s playing state. For a better resource management, a custom player wrapper to manage the player items and to control the play/pause flow better can be necessary.

THE VALUE OF AUDIOPLAYER 

The iOSAudioPlayer tries to make a bridge between the app’s player specifications and the available functionality of the native iOS components. It makes the native player components easier to be used and does the process and media files management that normally have to be taken care of by the developer. It can be incorporated in any UI component and has the following advantages:

    1. Having only one method for both play and pause a certain media file

    2. Completion handlers for the most important features are available, this way the the play flow is more organised

    3. Notifications triggered for the most important player and player items states

    4. Media resource management is done by framework itself 

    5. Player will be able to play in background and be controlled from springboard in sleep state 

    6. The play video flow is controlled with simple and intuitive methods 

TECHNOLOGY

The framework represents a complete wrapper written in Swift over the common known AVPlayer component. It exposes a single method for play and pause, being able to determine which process to perform and to control it’s own play / pause functionality, along with taking decision when to change the player item. It uses a single method for skipping a certain time interval, using a custom type defined for determining the direction. It also implements the functionality of seeking to a certain offset. It triggers notifications for all the main player’s states and in addition it triggers notifications for each packet of the media file which is loaded. This way it can be exposed to the user how much of the already playing media file is loaded.   

You can find the complete source code and a demo project under our 3PillarLabs GitHub account: https://github.com/3pillarlabs/ios-audio-player

We also created a short video that will show you step-by-step how to easily integrate the framework into your iOS application.