Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noreasonprojects/ModernAVPlayer
ModernAVPlayer is a persistence AVPlayer wrapper
https://github.com/noreasonprojects/ModernAVPlayer
audio avaudiosession avplayer avplayeritem cocoapods persistence pod rxswift spm state-machine swift swiftpackagemanager wrapper
Last synced: 3 months ago
JSON representation
ModernAVPlayer is a persistence AVPlayer wrapper
- Host: GitHub
- URL: https://github.com/noreasonprojects/ModernAVPlayer
- Owner: noreasonprojects
- License: mit
- Created: 2018-04-07T16:14:11.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2022-10-06T03:32:27.000Z (about 2 years ago)
- Last Synced: 2024-07-24T17:49:10.234Z (3 months ago)
- Topics: audio, avaudiosession, avplayer, avplayeritem, cocoapods, persistence, pod, rxswift, spm, state-machine, swift, swiftpackagemanager, wrapper
- Language: Swift
- Homepage:
- Size: 50.9 MB
- Stars: 281
- Watchers: 8
- Forks: 46
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - ModernAVPlayer - Persistence player to resume playback after bad network connection even in background mode, manage headphone interactions, system interruptions, now playing informations and remote commands. (Media / Audio)
- awesome-swift - ModernAVPlayer - Persistence AVPlayer to resume playback after bad network connection even in background mode. (Libs / Audio)
- awesome-video - noreasonprojects/ModernAVPlayer - ModernAVPlayer is a persistence AVPlayer wrapper. (Players / iOS tvOS)
- awesome-swift - ModernAVPlayer - Persistence AVPlayer to resume playback after bad network connection even in background mode. (Libs / Audio)
- fucking-awesome-swift - ModernAVPlayer - Persistence AVPlayer to resume playback after bad network connection even in background mode. (Libs / Audio)
- awesome-ios-star - ModernAVPlayer - Persistence player to resume playback after bad network connection even in background mode, manage headphone interactions, system interruptions, now playing informations and remote commands. (Media / Audio)
- awesome-swift - ModernAVPlayer - ModernAVPlayer is a persistence AVPlayer wrapper ` 📝 6 months ago ` (Audio [🔝](#readme))
README
# ModernAVPlayer
![Swift 4.2](https://img.shields.io/badge/Swift-5-orange.svg)
[![Build Status](https://travis-ci.org/noreasonprojects/ModernAVPlayer.svg?branch=develop)](https://travis-ci.com/noreasonprojects/ModernAVPlayer)
![CocoaPods](https://img.shields.io/cocoapods/v/ModernAVPlayer.svg)
![CocoaPods](https://img.shields.io/cocoapods/l/ModernAVPlayer.svg)``ModernAVPlayer`` is a persistence ``AVPlayer`` wrapper
#### ++ Cool features ++
- Get 9 nice and relevant player states (playing, buffering, loading, loaded...)
- Persistence player to resume playback after bad network connection ~~even in background mode~~ (bug from version 1.5.1)
- Manage headphone interactions, call & siri interruptions, now playing informations
- Add your own plug-in to manage tracking, events...
- RxSwift compatible
- Loop mode
- Log available by domain
***### Known issue
From version 1.5.1, resume playback from background mode failed. If you have any suggestion, please help.``Use of mixWithOther AVAudiosession CategoryOptions is not a solution.``
***## Menu
- [Requirements](#requirements)
- [Installation](#installation)
- [Getting started](#getting-started)
- [Advanced](#advanced)
- [Custom Configuration](#custom-configuration)
- [Remote Command](#remote-command)
- [Plugin](#plugin)
- [RxSwift](#rxswift)
- [Communication](#communication)## Requirements
- iOS 10.0+
- tvOS 10.0+> In order to support background mode, append the following to your ``Info.plist``:
```
UIBackgroundModesaudio
```
## Installation
### Swift Package Manager
Supported version: ``swift-tools-version:5.0``
```swift
// Package.swiftimport PackageDescription
let package = Package(
name: "Sample",
dependencies: [
.package(url: "https://github.com/noreasonprojects/ModernAVPlayer", from: "X.X.X")
],
targets: [
.target(name: "Sample", dependencies: ["ModernAVPlayer"])
]
)
```### CocoaPods
[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:
```bash
$ gem install cocoapods
```> CocoaPods 1.3+ is required to build ModernAVPlayer.
To integrate ``ModernAVPlayer`` into your Xcode project using CocoaPods, specify it in your `Podfile`:
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!target '' do
pod 'ModernAVPlayer'
end
```Then, run the following command:
```bash
$ pod install
```## Getting started
> Create media from URL
```swift
let media = ModernAVPlayerMedia(url: URL, type: MediaType)
```
> Create media from AVPlayerItem
```swift
let media = ModernAVPlayerMediaItem(item: AVPlayerItem, type: MediaType, metadata: PlayerMediaMetadata)
```> Instanciate the wrapper
```swift
let player = ModernAVPlayer()
```
> Load and play the media
```swift
player.load(media: media, autostart: true)
```
> Track on repeat
```swift
player.loopMode = true
```| ↓ State / Command → | loadMedia | play | pause | stop | seek |
|:---------|:---------:|:--------:|:--------:|:--------:|:--------:|
| Init | O | X | O | O | X
| Loading | O | X | O | O | X
| Loaded | O | O | O | O | O
| Buffering | O | X | O | O | O
| Playing | O | X | O | O | O
| Paused | O | O | X | O | O
| Stopped | O | O | O | X | O
| WaitingNetwork | O | X | O | O | X
| Failed | O | O | X | X | X## Advanced
### Custom configuration
All player configuration are available from `PlayerConfiguration` protocol.
A default implementation `ModernAVPlayerConfiguration` is provided with documentation---
### Remote command
If using default configuration file ( `swift useDefaultRemoteCommand = true`), ModernAVPlayer use **automatically** all commands created by `ModernAVPlayerRemoteCommandFactory` class
Documention available in `ModernAVPlayerRemoteCommandFactory.swift` file#### Custom command
> Use your own `PlayerConfiguration` implementation with
```swift
...
useDefaultRemoteCommand = false
...
```> Create an array of commands conforming to `ModernAVPlayerRemoteCommand` protocol.
```swift
let player = ModernAVPlayer(config: YourConfigImplementation())
let commands: [ModernAVPlayerRemoteCommand] = YourRemoteCommandFactory.commands
player.remoteCommands = commands
```You can use existing commands from public `ModernAVPlayerRemoteCommandFactory` class.
---
### Plugin
Use `PlayerPlugin` protocol to create your own plugin system, like tracking Plugin.
---
### RxSwift
Instead of using delegate pattern, you can use rx to bind player attributes.
> Setup
Use `pod 'ModernAVPlayer/RxSwift'` in the Podfile
> Usage
```swift
let player = ModernAVPlayer()
let state: Observable = player.rx.state
```## Communication
- If you **found a bug**, make a pull request using `Simple Audio` template in the example section to demonstrate.
- If you **have a feature request**, open an issue.
- If you **want to contribute**, submit a pull request.