All Projects → eMdOS → AirPlay

eMdOS / AirPlay

Licence: MIT license
Small framework that lets users track iOS AirPlay availability and extra features.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to AirPlay

Natrium
A pre-build (Swift) script to alter your Xcode project at pre-build-time per environment, build configuration and target.
Stars: ✭ 131 (+184.78%)
Mutual labels:  carthage, swift-package-manager
Kvkcalendar
A most fully customization calendar and timeline library for iOS 📅
Stars: ✭ 160 (+247.83%)
Mutual labels:  carthage, swift-package-manager
Coregpx
A library for parsing and creation of GPX location files. Purely Swift.
Stars: ✭ 132 (+186.96%)
Mutual labels:  carthage, swift-package-manager
Randomkit
Random data generation in Swift
Stars: ✭ 1,458 (+3069.57%)
Mutual labels:  carthage, swift-package-manager
Carting
🚘 A simple tool for updating Carthage script phase
Stars: ✭ 182 (+295.65%)
Mutual labels:  carthage, swift-package-manager
Skeletonview
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting
Stars: ✭ 10,804 (+23386.96%)
Mutual labels:  carthage, swift-package-manager
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (+243.48%)
Mutual labels:  carthage, swift-package-manager
Xmlmapper
A simple way to map XML to Objects written in Swift
Stars: ✭ 90 (+95.65%)
Mutual labels:  carthage, swift-package-manager
Validated
A rule-based validation framework
Stars: ✭ 31 (-32.61%)
Mutual labels:  carthage, swift-package-manager
L10n Swift
Localization of the application with ability to change language "on the fly" and support for plural form in any language.
Stars: ✭ 177 (+284.78%)
Mutual labels:  carthage, swift-package-manager
Alamofire
Elegant HTTP Networking in Swift
Stars: ✭ 36,896 (+80108.7%)
Mutual labels:  carthage, swift-package-manager
Amplitude Ios
Native iOS/tvOS/macOS SDK
Stars: ✭ 216 (+369.57%)
Mutual labels:  carthage, swift-package-manager
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+23173.91%)
Mutual labels:  carthage, swift-package-manager
Bettersegmentedcontrol
An easy to use, customizable replacement for UISegmentedControl & UISwitch.
Stars: ✭ 1,782 (+3773.91%)
Mutual labels:  carthage, swift-package-manager
Buckets Swift
Swift Collection Data Structures Library
Stars: ✭ 106 (+130.43%)
Mutual labels:  carthage, swift-package-manager
Ducttape
📦 KeyPath dynamicMemberLookup based syntax sugar for Swift.
Stars: ✭ 138 (+200%)
Mutual labels:  carthage, swift-package-manager
Swiftlinkpreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images.
Stars: ✭ 1,216 (+2543.48%)
Mutual labels:  carthage, swift-package-manager
Freedom
The Freedom to Open URLs in Third-Party Browsers on iOS with Custom UIActivity Subclasses.
Stars: ✭ 85 (+84.78%)
Mutual labels:  carthage, swift-package-manager
Multipeer
📱📲 A wrapper for the MultipeerConnectivity framework for automatic offline data transmission between devices
Stars: ✭ 170 (+269.57%)
Mutual labels:  carthage, swift-package-manager
Aksidemenu
Beautiful iOS side menu library with parallax effect. Written in Swift
Stars: ✭ 216 (+369.57%)
Mutual labels:  carthage, swift-package-manager

AirPlay

CI Status Version License Platform

AirPlay lets users track iOS AirPlay availability and provides extra information about AirPlay connections.

Development Environment

  • Xcode 8.2.1 (8C1002)
  • Swift 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
  • CocoaPods 1.2.0

Support

iOSSupport

Currently, this library is a kind of workaround to be able to track AirPlay availability observing changes on MPVolumeView. So, it needs to be tested every new iOS release.

If there is an Apple TV or other AirPlay-enabled device in range, the route button allows the user to choose it. If there is only one audio output route available, the route button is not displayed.

PLEASE READ:

When developers provide workarounds (like I'm doing "to detect" AirPlay's availability) related to private APIs or closed classes (via KVO), Apple uses to stop supporting those properties in order to push developers to stop using them.

Seems like for iOS 10+, Apple stopped supporting alpha property from MPVolumeView. So, it could results in always having isAvailable static property returning true; I'm unsure, I need to dig deeper and do a more exaustive QA.

Please let me know if you find any issue.

Usage

Notifications, Properties, Methods, Closures

Notifications

Notification Description
.airplayAvailabilityChangedNotification Notification sent everytime AirPlay availability changes.
.airplayRouteStatusChangedNotification Notification sent everytime AirPlay connection route changes.

Properties

Property Description
isAvailable RReturns true or false if there are or not available devices for casting via AirPlay. (read-only)
isBeingMonitored Returns true or false if AirPlay availability is being monitored or not. (read-only)
isConnected Returns true or false if device is connected or not to a second device via AirPlay. (read-only)
connectedDevice Returns Device's name if connected, if not, it returns nil. (read-only)

Methods

Method Description
startMonitoring() Starts monitoring AirPlay availability changes.
stopMonitoring() Stops monitoring AirPlay availability changes.

Closures

Closure Description
whenAvailable Closure called when is available to cast media via AirPlay.
whenUnavailable Closure called when is not available to cast media via AirPlay.
whenRouteChanged Closure called when route changed.

Start Monitoring

What I use to do is to start monitoring in the AppDelegate. It can be implemented anywhere.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    AirPlay.startMonitoring()
    return true
}

Adding/Removing Observers

To add them:

NotificationCenter.default.addObserver(
    self,
    selector: #selector(<selector>),
    name: .airplayAvailabilityChangedNotification,
    object: nil
)
NotificationCenter.default.addObserver(
    self,
    selector: #selector(<selector>),
    name: .airplayRouteStatusChangedNotification,
    object: nil
)

To remove them:

NotificationCenter.default.removeObserver(
    self,
    name: .airplayAvailabilityChangedNotification,
    object: nil
)
NotificationCenter.default.removeObserver(
    self,
    name: .airplayRouteStatusChangedNotification,
    object: nil
)

Using closures

When available:

AirPlay.whenAvailable = { [weak self] in
    <code>
}

When unavailable:

AirPlay.whenUnavailable = { [weak self] in
    <code>
}

When route changed:

AirPlay.whenRouteChanged = { [weak self] in
    <code>
}

Displaying AirPlay availability status

AirPlay.isAvailable will return true or false.

Displaying AirPlay connection status

AirPlay.isConnected will return true of false.

Displaying connected device name

AirPlay.connectedDevice ?? "Unknown Device"

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.2.0 is required to guarantee AirPlay v3.0.0+ will build.

To integrate AirPlay into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'AirPlay', '~> 3.0.0'

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate AirPlay into your Xcode project using Carthage, specify it in your Cartfile:

github "eMdOS/AirPlay" ~> 3.0.0

Run carthage update to build the framework and drag the built AirPlay.framework into your Xcode project.

Migration from v1.+ to v3.+

I skipped version 2 just to match with the swift language version.

Changed

  • Notifications naming.

    • .airplayAvailabilityChangedNotification

      ... was AirPlayAvailabilityChangedNotification.

    • .airplayRouteStatusChangedNotification

      ... was AirPlayRouteStatusChangedNotification.

  • Properties naming.

    • AirPlay.isAvailable

      ... was AirPlay.isPossible.

  • Closures naming.

    • AirPlay.whenAvailable

      ... was AirPlay.whenPossible.

    • AirPlay.whenUnavailable

      ... was AirPlay. whenNotPossible.

    • AirPlay.whenRouteChanged

      ... was AirPlay.whenConnectionChanged.

Author

eMdOS

License

AirPlay is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].