Skip to content

kacpiii/Keith

 
 

Repository files navigation

Keith

Build Status CocoaPods Version Carthage compatible GitHub release GitHub license

A media player for iOS written in Swift 3.0. Keith was based on the audio player implemented on https://github.com/jaredsinclair/sodes-audio-example.

Features

  • Generic audio and video player for iOS
  • Easier than setting up your own AVPlayer stack
  • No need to deal with key-value observing AVPlayer and AVPlayerItem properties yourself
  • Deals with audio session interruptions for you
  • Remote commands for Control Center

Keith does not include any UI elements. Only player logic.

Installation

Using CocoaPods:

use_frameworks!
pod 'Keith'

Using Carthage:

github "Movile/Keith"

Manually:

  1. Drag Keith.xcodeproj to your project in the Project Navigator.
  2. Select your project and then your app target. Open the Build Phases panel.
  3. Expand the Target Dependencies group, and add Keith.framework.
  4. Click on the + button at the top left of the panel and select New Copy Files Phase. Set Destination to Frameworks, and add Keith.framework.
  5. import Keith whenever you want to use Haneke.

Requirements

  • iOS 9.2+
  • Swift 3.0

Usage

To get started, first create a playback source.

let url = URL(string: "http://devstreaming.apple.com/videos/wwdc/2016/102w0bsn0ge83qfv7za/102/hls_vod_mvp.m3u8")!
let type: PlaybackSource.`Type` = .video

let source = PlaybackSource(url: url, type: type)

Then, set up the playback controller, which is Keith's working horse.

let playbackController = PlaybackController()
playbackController.prepareToPlay(source, playWhenReady: true, startTime: 0.0)

You can optionally use the playback controller's shared property to obtain a singleton instance. This may be useful when you need to retain the controller in your whole app's lifetime -- audio player app's are a common use case.

let playbackController = PlaybackController.shared

The playback controller supports standard operations (play, pause, toggle play/pause, skip forward/backward, seek) and has a status property to check for playback states.

It's possible to get the underlying AVPlayer from the playback controller and use it to include in an AVPlayerViewController, for example.

import AVKit

let playerViewController = AVPlayerViewController()
playerViewController.player = playbackController.player

Observe the following notifications to monitor changes in the playback state.

  • didBeginPlayback
  • didPausePlayback
  • didResumePlayback
  • didStopPlayback
  • willChangePositionTime
  • didChangePositionTime
  • didUpdateElapsedTime
  • didUpdateDuration
  • didUpdateStatus
  • didPlayToEnd
  • willChangePlaybackSource
  • didChangePlaybackSource

Name

Keith's name is a homage to Keith Richards, one of the greatest guitar players that ever existed and the embodiment of rock 'n roll itself.

If you've gotta think about being cool, you ain' cool

Keith Richards

About

A media player for iOS written in Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 97.6%
  • Ruby 1.2%
  • Objective-C 1.2%