Skip to content

Latest commit

 

History

History
154 lines (123 loc) · 8.19 KB

README.md

File metadata and controls

154 lines (123 loc) · 8.19 KB

RxAudioVisual

Build Status Swift 4.0 Carthage compatible Version License Platform

RxAudioVisual is a RxSwift wrapper around AVFoundation.

Requirements

Target Version
iOS => 10.0
Swift ~> 4.0
RxSwift / RxCocoa ~> 4.0

Installation

RxAudioVisual is available through CocoaPods.

CocoaPods

pod "RxAudioVisual"

Getting started

AVAsynchronousKeyValueLoading

asset.rx.playable.subscribe(
  onSuccess: { playable in
    // Do something nice.
  }
)

KVO

player.rx.status.filter { $0 == .readyToPlay }.subscribe(onNext: { _ in
  player.play()
}).addDisposableTo(self.disposeBag)
playerLayer.rx.readyForDisplay.filter { $0 == true }.subscribe(onNext: { [weak self] _ in
  playerLayer.frame = self?.videoView.bounds
  self?.videoView.layer.addSublayer(playerLayer)
}).addDisposableTo(self.disposeBag)

Notification

item.rx.didPlayToEnd.subscribe(onNext: { _ in
  player.seek(to: kCMTimeZero)
  player.play()
}).addDisposableTo(self.disposeBag)

Overview

AVAsset

property ObservableType Element
duration Single CMTime
preferredRate Single Float
preferredVolume Single Float
preferredTransform Single CGAffineTransform
tracks Single [AVAssetTrack]
playable Single Bool
exportable Single Bool
readable Single Bool
composable Single Bool
compatibleWithSavedPhotosAlbum Single Bool
compatibleWithAirPlayVideo Single Bool

AVAssetTrack

property ObservableType Element
playable Single Bool
enabled Single Bool
selfContained Single Bool
totalSampleDataLength Single Int64
timeRange Single CMTimeRange
naturalTimeScale Single CMTimeScale
estimatedDataRate Single Float
naturalSize Single CGSize
preferredTransform Single CGAffineTransform
preferredVolume Single Float
nominalFrameRate Single Float

AVPlayer

property ObservableType Element
status Observable AVPlayerStatus
error Observable NSError?
timeControlStatus Observable AVPlayerTimeControlStatus
rate Observable Float
currentItem Observable AVPlayerItem?
actionAtItemEnd Observable AVPlayerActionAtItemEnd
volume Observable Float
muted Observable Bool
closedCaptionDisplayEnabled Observable Bool
allowsExternalPlayback Observable Bool
externalPlaybackActive Observable Bool
usesExternalPlaybackWhileExternalScreenIsActive Observable Bool

AVPlayerItem

property ObservableType Element
asset Observable AVAsset?
duration Observable CMTime
error Observable NSError?
loadedTimeRanges Observable [NSValue]
presentationSize Observable CMTime
status Observable AVPlayerItemStatus
timebase Observable CMTimebase?
tracks Observable [AVPlayerItemTrack]
seekableTimeRanges Observable [NSValue]
isPlaybackLikelyToKeepUp Observable Bool
isPlaybackBufferEmpty Observable Bool
isPlaybackBufferFull Observable Bool
didPlayToEnd Observable Notification
timeJumped Observable Notification
failedToPlayToEndTime Observable Notification
playbackStalled Observable Notification
newAccessLogEntry Observable Notification
newErrorLogEntry Observable Notification

AVPlayerLayer

property ObservableType Element
player Observable AVPlayer?
readyForDisplay Observable Bool
videoRect Observable CGRect

Author

keita.oouchi, keita.oouchi@gmail.com

License

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