SDLoopingVideoView 2.0

SDLoopingVideoView 2.0

Maintained by John Solsma.



  • By
  • SolsmaHawk

SDLoopingVideoView

CI Status Version License Platform Swift

Description

SDLoopingVideoView is a looping video-view based off of AVPlayerLayer; it works great when used as a video background (see below for list of apps using SDLoopingVideoView). SDLoopingVideoView automatically scales any video displayed to aspect-fill the view you define; scaling can be set manually as well. SDLoopingVideoView responds to any UIView animations and scales accordingly without interuption of the video playing.

Example

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

Requirements

Swift 5.0

Installation

SDLoopingVideoView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SDLoopingVideoView'

How to use

Interface Builder

The easiest way to create a SDLoopingVideoView is to drag and drop a UIView in interface builder and set its class to SDLoopingVideoView. Then, under the attributes inspector tab, set the videoName property to the name of your video file and set the videoType property to the extension of your video file.

Programatically

You can also initialize an SDLoopingVideoView by declaring it in code:

let loopingVideoView = SDLoopingVideoView.init(frame: 
CGRect.init(x: 0, y: 0, width: 200, height: 200), 
videoName: "your_video_name", 
videoType: "mp4")
view.addSubview(loopingVideoView)

Or if you want to manually set scaling (defaults to aspect-fill):

let loopingVideoView = SDLoopingVideoView.init(frame: 
CGRect.init(x: 0, y: 0, width: 200, height: 200), 
videoName: "your_video_name", 
videoType: "mp4",
scaling: .resizeAspectFill)
view.addSubview(loopingVideoView)

Simple!

Get Creative

You can setup multiple SDLoopingVideoViews to display simultaneously. (Video game footage taken from Velocity Breaker by Solsma Dev, available in the App Store.)

Author

John Solsma (Solsma Dev Inc.), [email protected], http://SolsmaDev.com

Apps using SDLoopingVideoView

If you're using SDLoopingVideoView in a public app, email me ([email protected]) and I will add it to the list!

Velocity Breaker (tvOS + iOS)

Jungle Card Match

IMT Insurance Worry Free App

License

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