ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - noreasonprojects/ModernAVPlayer: ModernAVPlayer is a persistence AVPlayer wrapper
ModernAVPlayer is a persistence AVPlayer wrapper. Contribute to noreasonprojects/ModernAVPlayer development by creating an account on GitHub.
Visit Site

GitHub - noreasonprojects/ModernAVPlayer: ModernAVPlayer is a persistence AVPlayer wrapper

GitHub - noreasonprojects/ModernAVPlayer: ModernAVPlayer is a persistence AVPlayer wrapper

ModernAVPlayer

Swift 4.2 Build Status CocoaPods CocoaPods

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

  • iOS 10.0+
  • tvOS 10.0+

In order to support background mode, append the following to your Info.plist:

<key>UIBackgroundModes</key>
<array>
    <string>audio</string>
</array>

Installation

Swift Package Manager

Supported version: swift-tools-version:5.0

// Package.swift

import 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 is a dependency manager for Cocoa projects. You can install it with the following command:

$ 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:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'ModernAVPlayer'
end

Then, run the following command:

$ pod install

Getting started

Create media from URL

let media = ModernAVPlayerMedia(url: URL, type: MediaType)

Create media from AVPlayerItem

let media = ModernAVPlayerMediaItem(item: AVPlayerItem, type: MediaType, metadata: PlayerMediaMetadata)

Instanciate the wrapper

let player = ModernAVPlayer()

Load and play the media

player.load(media: media, autostart: true)

Track on repeat

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

...
useDefaultRemoteCommand = false
...

Create an array of commands conforming to ModernAVPlayerRemoteCommand protocol.

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

let player = ModernAVPlayer()
let state: Observable<ModernAVPlayer.State> = 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.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory