Compare commits

..

4 Commits

Author SHA1 Message Date
Jørgen Henrichsen 09a7548f3a Update README. Update podspec.
Bump verision to 0.11.0.
2019-07-12 18:13:46 +02:00
Jørgen Henrichsen 565b9a04d4 Merge pull request #71 from dcvz/feature/asset-options
Add ability to set asset init options
2019-07-12 18:12:23 +02:00
David Chavez c2ec751ec0 Address review feedback 2019-07-10 13:56:05 +02:00
David Chavez 2c36c6c239 Add ability to set asset init options 2019-07-06 12:04:49 +02:00
6 changed files with 37 additions and 10 deletions
+2 -2
View File
@@ -25,13 +25,13 @@ SwiftAudio is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'SwiftAudio', '~> 0.10.0'
pod 'SwiftAudio', '~> 0.11.0'
```
### Carthage
SwiftAudio supports [Carthage](https://github.com/Carthage/Carthage). Add this to your Cartfile:
```ruby
github "jorgenhenrichsen/SwiftAudio" ~> 0.10.0
github "jorgenhenrichsen/SwiftAudio" ~> 0.11.0
```
Then follow the rest of Carthage instructions on [adding a framework](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application).
+1 -1
View File
@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = 'SwiftAudio'
s.version = '0.10.0'
s.version = '0.11.0'
s.summary = 'Easy audio streaming for iOS'
s.description = <<-DESC
SwiftAudio is an audio player written in Swift, making it simpler to work with audio playback from streams and files.
@@ -170,7 +170,7 @@ class AVPlayerWrapper: AVPlayerWrapperProtocol {
func load(from url: URL, playWhenReady: Bool) {
func load(from url: URL, playWhenReady: Bool, options: [String: Any]? = nil) {
reset(soft: true)
_playWhenReady = playWhenReady
@@ -178,7 +178,7 @@ class AVPlayerWrapper: AVPlayerWrapperProtocol {
recreateAVPlayer()
}
self._pendingAsset = AVURLAsset(url: url)
self._pendingAsset = AVURLAsset(url: url, options: options)
if let pendingAsset = _pendingAsset {
self._state = .loading
@@ -226,10 +226,10 @@ class AVPlayerWrapper: AVPlayerWrapperProtocol {
}
}
func load(from url: URL, playWhenReady: Bool, initialTime: TimeInterval?) {
func load(from url: URL, playWhenReady: Bool, initialTime: TimeInterval? = nil, options: [String : Any]? = nil) {
_initialTime = initialTime
self.pause()
self.load(from: url, playWhenReady: playWhenReady)
self.load(from: url, playWhenReady: playWhenReady, options: options)
}
// MARK: - Util
@@ -49,8 +49,8 @@ protocol AVPlayerWrapperProtocol: class {
func seek(to seconds: TimeInterval)
func load(from url: URL, playWhenReady: Bool)
func load(from url: URL, playWhenReady: Bool, options: [String: Any]?)
func load(from url: URL, playWhenReady: Bool, initialTime: TimeInterval?)
func load(from url: URL, playWhenReady: Bool, initialTime: TimeInterval?, options: [String: Any]?)
}
+26
View File
@@ -36,6 +36,11 @@ public protocol InitialTiming {
func getInitialTime() -> TimeInterval
}
/// Make your `AudioItem`-subclass conform to this protocol to set initialization options for the asset. Available keys available at [Apple Developer Documentation](https://developer.apple.com/documentation/avfoundation/avurlasset/initialization_options).
public protocol AssetOptionsProviding {
func getAssetOptions() -> [String: Any]
}
public class DefaultAudioItem: AudioItem {
public var audioUrl: String
@@ -125,3 +130,24 @@ public class DefaultAudioItemInitialTime: DefaultAudioItem, InitialTiming {
}
}
/// An AudioItem that also conforms to the `AssetOptionsProviding`-protocol
public class DefaultAudioItemAssetOptionsProviding: DefaultAudioItem, AssetOptionsProviding {
public var options: [String: Any]
public override init(audioUrl: String, artist: String?, title: String?, albumTitle: String?, sourceType: SourceType, artwork: UIImage?) {
self.options = [:]
super.init(audioUrl: audioUrl, artist: artist, title: title, albumTitle: albumTitle, sourceType: sourceType, artwork: artwork)
}
public init(audioUrl: String, artist: String?, title: String?, albumTitle: String?, sourceType: SourceType, artwork: UIImage?, options: [String: Any]) {
self.options = options
super.init(audioUrl: audioUrl, artist: artist, title: title, albumTitle: albumTitle, sourceType: sourceType, artwork: artwork)
}
public func getAssetOptions() -> [String: Any] {
return options
}
}
+2 -1
View File
@@ -161,7 +161,8 @@ public class AudioPlayer: AVPlayerWrapperDelegate {
wrapper.load(from: url,
playWhenReady: playWhenReady,
initialTime: (item as? InitialTiming)?.getInitialTime())
initialTime: (item as? InitialTiming)?.getInitialTime(),
options:(item as? AssetOptionsProviding)?.getAssetOptions())
self._currentItem = item