iDevelopper / PBMediaSlider

PBMediaSlider is a small Swift Package aiming to recreate volume and track sliders found in Apple Music on iOS 16 and later.
MIT License
4 stars 0 forks source link

PBMediaSlider

CI Status Version License Platform Swift: 5.9 Swift Package Manager: compatible

Overview

PBMediaSlider is a small Swift Package aiming to recreate volume and track sliders found in Apple Music on iOS 16 and later. PBMediaSlider maintains an API similar to built-in UISlider. It has the same properties, like value and isContinuous. Progress observation is done the same way, by adding a target and an action:

sliderControl.addTarget(self, action: #selector(sliderValueChanged), for: .valueChanged)

Alternatively, you can subscribe to valuePublisher publisher to receive value updates:

 var cancellablePublisher: AnyCancellable!
 ...
 self.cancellablePublisher = slider.publisher(for: .valueChanged).sink { slider in
     if let slider = slider as? PBMediaSlider {
         print("slider value: \(slider.value)")
     }
 }

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

Swift Package Manager

PBMediaSlider supports SPM versions 5.1.0 and above. To use SPM, you should use Xcode 11 or above to open your project. Click File -> Swift Packages -> Add Package Dependency, enter https://github.com/iDevelopper/PBMediaSlider. Select the version you’d like to use.

Carthage

Add the following to your Cartfile:

github "iDevelopper/PBMediaSlider"

Make sure you follow the Carthage integration instructions here.

CocoaPods

PBMediaSlider is available for installation using the Cocoa dependency manager CocoaPods.

Add the following to your project's Podfile:

pod 'PBMediaSlider'

Requirements

Features

Author

Patrick BODET aka iDevelopper

License

PBMediaSlider is available under the MIT license, see the LICENSE file for more information.

Please tell me when you use this controller in your project!

Regards,

Patrick Bodet aka iDevelopper