Skip to content

Commit 51a0b9c

Browse files
authored
Merge pull request #13 from quanvo87/master
2.0.0
2 parents 9c7c24e + 8785613 commit 51a0b9c

27 files changed

+911
-554
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.DS_Store
22
build/
3+
xcuserdata/

Assets/add-video-to-project.png

130 KB
Loading

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Change Log
22

3+
## [2.0.0](https://github.com/dingwilson/SwiftVideoBackground/tree/2.0.0) (2017-12-14)
4+
**Major Release: BREAKING CHANGES**
5+
- renamed class from `BackgroundVideo` to `VideoBackground` for consistency with package name
6+
- class is no longer a subclass of `UIView`
7+
- instantiate an instance simply with `let videoBackground = VideoBackground()`
8+
- only one API is exposed, `play()`. `play()` requires a `UIView` passed in. It will play your video on this view. Typical usage would just be to pass in the `UIView` class property of your `UIViewController`.
9+
10+
For more information, please see the [documentation](http://wilsonding.com/SwiftVideoBackground/)
11+
12+
For an example and help with migrating from previous verisons, please see the [migration guide](migration-2.0.0.md)
13+
314
## [1.0.1](https://github.com/dingwilson/SwiftVideoBackground/tree/1.0.1) (2017-10-31)
415
- Modified minimum deployment target to iOS 8.0
516

README-0.06.md

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<p align="center">
2+
<img src="Assets/banner.png" width="780" title="SwiftVideoBackground">
3+
</p>
4+
5+
[![CocoaPods Version Status](https://img.shields.io/cocoapods/v/SwiftVideoBackground.svg)][podLink]
6+
[![Carthage compatible](https://img.shields.io/badge/Carthage-Compatible-brightgreen.svg?style=flat)](https://github.com/Carthage/Carthage)
7+
[![CocoaPods](https://img.shields.io/cocoapods/dt/SwiftVideoBackground.svg)](https://cocoapods.org/pods/SwiftVideoBackground)
8+
[![CocoaPods](https://img.shields.io/cocoapods/dm/SwiftVideoBackground.svg)](https://cocoapods.org/pods/SwiftVideoBackground)
9+
![Platform](https://img.shields.io/badge/platforms-iOS-333333.svg)
10+
[![Swift](https://img.shields.io/badge/Swift-3.0+-orange.svg)](https://swift.org)
11+
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)][mitLink]
12+
13+
<p align="center">
14+
<img src="Assets/Spotify.gif" width="369" title="Screenshot">
15+
</p>
16+
17+
SwiftVideoBackground is an easy to use Swift framework that provides the ability to add a UIView of a video playing in the background to any ViewController. This provides a beautiful UI for login screens, or splash pages, as implemented by Spotify and many others.
18+
19+
1. [Requirements](#requirements)
20+
2. [Integration](#integration)
21+
- [Cocoapods](#cocoapods)
22+
- [Carthage](#carthage)
23+
- [Manually](#manually)
24+
3. [Usage](#usage)
25+
4. [License](#license)
26+
27+
## Requirements
28+
29+
- Swift 3+
30+
- iOS 8+
31+
32+
## Integration
33+
34+
#### CocoaPods
35+
You can use [CocoaPods](http://cocoapods.org/) to install `SwiftVideoBackground` by adding it to your `Podfile`:
36+
37+
For Swift 3:
38+
```ruby
39+
pod 'SwiftVideoBackground', '~> 0.06'
40+
```
41+
42+
#### Carthage
43+
You can use [Carthage](https://github.com/Carthage/Carthage) to install `SwiftVideoBackground` by adding it to your `Cartfile`:
44+
```
45+
github "dingwilson/SwiftVideoBackground"
46+
```
47+
48+
#### Manually
49+
50+
To use this library in your project manually you may:
51+
52+
1. for Projects, just drag BackgroundVideo.swift to the project tree
53+
2. for Workspaces, include the whole SwiftVideoBackground.xcodeproj
54+
55+
## Usage
56+
57+
Import the framework into the ViewController
58+
```swift
59+
import SwiftVideoBackground
60+
```
61+
62+
Link a UIView within a ViewController within the Storyboard to a BackgroundVideo item, or link it programmatically.
63+
```swift
64+
var backgroundVideo : BackgroundVideo!
65+
```
66+
67+
Use the `createBackgroundVideo` function, with the name of the video or gif under `name`, and the file type under `type`. You can also include an alpha value between 0 and 1 under `alpha`, to adjust the brightness of the video.
68+
```swift
69+
backgroundVideo.createBackgroundVideo(name: "Background", type: "mp4")
70+
```
71+
```swift
72+
backgroundVideo.createBackgroundVideo(name: "Background", type: "mp4", alpha: 0.5)
73+
```
74+
75+
Note: Make sure you have added a video file to the project, and targeted the project. Also, make sure that you have set the module to `SwiftVideoBackground` for the BackgroundVideo UIView.
76+
77+
## License
78+
79+
`SwiftVideoBackground` is released under an [MIT License][mitLink]. See `LICENSE` for details.
80+
81+
**Copyright &copy; 2016-present Wilson Ding.**
82+
83+
*Please provide attribution, it is greatly appreciated.*
84+
85+
[podLink]:https://cocoapods.org/pods/SwiftVideoBackground
86+
[mitLink]:http://opensource.org/licenses/MIT

README.md

+63-26
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@
1414
<img src="Assets/Spotify.gif" width="369" title="Screenshot">
1515
</p>
1616

17-
SwiftVideoBackground is an easy to use Swift framework that provides the ability to add a UIView of a video playing in the background to any ViewController. This provides a beautiful UI for login screens, or splash pages, as implemented by Spotify and many others.
17+
SwiftVideoBackground is an easy to use Swift framework that provides the ability to play a video on any UIView. This provides a beautiful UI for login screens, or splash pages, as implemented by Spotify and many others.
1818

19-
1. [Requirements](#requrements)
19+
1. [Requirements](#requirements)
2020
2. [Integration](#integration)
21-
- [Cocoapods](#cocoapods)
21+
- [CocoaPods](#cocoapods)
2222
- [Carthage](#carthage)
2323
- [Manually](#manually)
24-
3. [Usage](#usage)
25-
4. [License](#license)
24+
3. [Migration Guide](#migration-guide)
25+
4. [Usage](#usage)
26+
5. [License](#license)
27+
6. [Authors](#authors)
2628

2729
## Requirements
2830

@@ -36,7 +38,7 @@ You can use [CocoaPods](http://cocoapods.org/) to install `SwiftVideoBackground`
3638

3739
For Swift 4:
3840
```ruby
39-
pod 'SwiftVideoBackground'
41+
pod 'SwiftVideoBackground', '~> 2.0.0'
4042
```
4143

4244
For Swift 3:
@@ -54,39 +56,74 @@ github "dingwilson/SwiftVideoBackground"
5456

5557
To use this library in your project manually you may:
5658

57-
1. for Projects, just drag BackgroundVideo.swift to the project tree
59+
1. for Projects, just drag VideoBackground.swift to the project tree
5860
2. for Workspaces, include the whole SwiftVideoBackground.xcodeproj
5961

62+
## Migration Guide
63+
64+
Version 2.0.0 brings improvements and breaking changes. See the quick migration guide [here](migration-2.0.0.md).
65+
6066
## Usage
6167

62-
Import the framework into the ViewController
63-
```swift
64-
import SwiftVideoBackground
65-
```
68+
#### Example
6669

67-
Link a UIView within a ViewController within the Storyboard to a BackgroundVideo item, or link it programmatically.
68-
```swift
69-
var backgroundVideo : BackgroundVideo!
70-
```
70+
``` swift
71+
import UIKit
72+
import VideoBackground
7173

72-
Use the `createBackgroundVideo` function, with the name of the video or gif under `name`, and the file type under `type`. You can also include an alpha value between 0 and 1 under `alpha`, to adjust the brightness of the video.
73-
```swift
74-
backgroundVideo.createBackgroundVideo(name: "Background", type: "mp4")
75-
```
76-
```swift
77-
backgroundVideo.createBackgroundVideo(name: "Background", type: "mp4", alpha: 0.5)
74+
class MyViewController: UIViewController {
75+
private let videoBackground = VideoBackground()
76+
77+
override func viewDidLoad() {
78+
super.viewDidLoad()
79+
80+
videoBackground.play(view: view, videoName: "myvideo", videoType: "mp4")
81+
}
82+
}
7883
```
7984

80-
Note: Make sure you have added a video file to the project, and targeted the project. Also, make sure that you have set the module to `SwiftVideoBackground` for the BackgroundVideo UIView.
85+
> Documentation for Version 0.06 (Swift 3) can be found [here](README-0.06.md).
86+
87+
#### Customization Options
88+
89+
`play()` has three additional optional parameters for customization:
90+
- `isMuted`: Bool - Indicates whether video is muted. Defaults to `true`.
91+
- `alpha`: CGFloat - Value between 0 and 1. The higher the value, the darker the video. Defaults to `0`.
92+
- `willLoopVideo`: Bool - Indicates whether video should restart when finished. Defaults to `true`.
8193

82-
To mute the video, simply set `isMuted` to true.
83-
```swift
84-
backgroundVideo.isMuted = true
94+
So for example:
95+
96+
``` swift
97+
videoBackground.play(view: view,
98+
videoName: "myvideo",
99+
videoType: "mp4",
100+
isMuted: false,
101+
alpha: 0.25,
102+
willLoopVideo: true)
85103
```
86104

105+
-> will play the video with the sound on, slightly darkened, and will continuously loop.
106+
107+
> Any combination of the three can be included or left out.
108+
109+
#### Adding Videos To Your Project
110+
111+
You must properly add videos to your project in order to play them. To do this:
112+
1. Open your project navigator
113+
2. Select your target
114+
3. Select `Build Phases`
115+
4. Select `Copy Bundle Resources`
116+
5. Click `+` to add a video
117+
118+
![add video to project](Assets/add-video-to-project.png "add video to project")
119+
87120
## License
88121

89-
`SwiftVideoBackground` is released under an [MIT License][mitLink]. See `LICENSE` for details.
122+
`SwiftVideoBackground` is released under an [MIT License][mitLink]. See [LICENSE](LICENSE) for details.
123+
124+
## Authors
125+
126+
[Wilson Ding](https://github.com/dingwilson), [Quan Vo](https://github.com/quanvo87)
90127

91128
**Copyright &copy; 2016-present Wilson Ding.**
92129

SwiftVideoBackground.podspec

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
Pod::Spec.new do |s|
22
s.name = "SwiftVideoBackground"
3-
s.version = "1.0.1"
3+
s.version = "2.0.0"
44
s.summary = "An easy to use Swift framework that creates a video background for any ViewController."
5-
s.description = "SwiftVideoBackground is an easy to use Swift framework that provides the ability to add a UIView of a video playing in the background to any ViewController. This provides a beautiful user interface for use in login screens, as well as other data input screens, as modeled by Spotify's iOS App Login Screen and others"
5+
s.description = "SwiftVideoBackground is an easy to use Swift framework that provides the ability to play a video on any UIView. This provides a beautiful UI for login screens, or splash pages, as implemented by Spotify and many others"
66
s.homepage = "https://github.com/dingwilson/SwiftVideoBackground"
77
s.license = { :type => "MIT", :file => "LICENSE" }
8-
s.author = { "Wilson Ding" => "[email protected]" }
8+
s.author = { "Wilson Ding" => "[email protected]",
9+
"Quan Vo" => "[email protected]" }
910
s.platform = :ios, "8.0"
10-
s.source = { :git => "https://github.com/dingwilson/SwiftVideoBackground.git", :tag => "1.0.1" }
11+
s.source = { :git => "https://github.com/dingwilson/SwiftVideoBackground.git", :tag => "2.0.0" }
1112
s.source_files = "SwiftVideoBackground", "SwiftVideoBackground/**/*.{h,m,swift}"
1213
s.exclude_files = "Classes/Exclude"
1314
end

SwiftVideoBackground.xcodeproj/project.pbxproj

+6-10
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
/* Begin PBXBuildFile section */
1010
C82AAF8B1D9C1C4800A13307 /* SwiftVideoBackgroundTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C82AAF8A1D9C1C4800A13307 /* SwiftVideoBackgroundTests.swift */; };
1111
C82AAF8D1D9C1C4800A13307 /* SwiftVideoBackground.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8D0633E1D99B62E006A5F00 /* SwiftVideoBackground.framework */; };
12-
C87103D91FA2380600F817BC /* BackgroundVideoError.swift in Sources */ = {isa = PBXBuildFile; fileRef = C87103D81FA2380600F817BC /* BackgroundVideoError.swift */; };
1312
C8D063431D99B62E006A5F00 /* SwiftVideoBackground.h in Headers */ = {isa = PBXBuildFile; fileRef = C8D063411D99B62E006A5F00 /* SwiftVideoBackground.h */; settings = {ATTRIBUTES = (Public, ); }; };
14-
C8D0634A1D99B639006A5F00 /* BackgroundVideo.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8D063491D99B639006A5F00 /* BackgroundVideo.swift */; };
13+
C8D0634A1D99B639006A5F00 /* VideoBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8D063491D99B639006A5F00 /* VideoBackground.swift */; };
1514
/* End PBXBuildFile section */
1615

1716
/* Begin PBXContainerItemProxy section */
@@ -28,11 +27,10 @@
2827
C82AAF881D9C1C4800A13307 /* SwiftVideoBackgroundTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftVideoBackgroundTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
2928
C82AAF8A1D9C1C4800A13307 /* SwiftVideoBackgroundTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftVideoBackgroundTests.swift; sourceTree = "<group>"; };
3029
C82AAF8C1D9C1C4800A13307 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
31-
C87103D81FA2380600F817BC /* BackgroundVideoError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundVideoError.swift; sourceTree = "<group>"; };
3230
C8D0633E1D99B62E006A5F00 /* SwiftVideoBackground.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftVideoBackground.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3331
C8D063411D99B62E006A5F00 /* SwiftVideoBackground.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftVideoBackground.h; sourceTree = "<group>"; };
3432
C8D063421D99B62E006A5F00 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
35-
C8D063491D99B639006A5F00 /* BackgroundVideo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundVideo.swift; sourceTree = "<group>"; };
33+
C8D063491D99B639006A5F00 /* VideoBackground.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoBackground.swift; sourceTree = "<group>"; };
3634
/* End PBXFileReference section */
3735

3836
/* Begin PBXFrameworksBuildPhase section */
@@ -84,8 +82,7 @@
8482
C8D063401D99B62E006A5F00 /* SwiftVideoBackground */ = {
8583
isa = PBXGroup;
8684
children = (
87-
C8D063491D99B639006A5F00 /* BackgroundVideo.swift */,
88-
C87103D81FA2380600F817BC /* BackgroundVideoError.swift */,
85+
C8D063491D99B639006A5F00 /* VideoBackground.swift */,
8986
C8D063411D99B62E006A5F00 /* SwiftVideoBackground.h */,
9087
C8D063421D99B62E006A5F00 /* Info.plist */,
9188
);
@@ -231,8 +228,7 @@
231228
isa = PBXSourcesBuildPhase;
232229
buildActionMask = 2147483647;
233230
files = (
234-
C87103D91FA2380600F817BC /* BackgroundVideoError.swift in Sources */,
235-
C8D0634A1D99B639006A5F00 /* BackgroundVideo.swift in Sources */,
231+
C8D0634A1D99B639006A5F00 /* VideoBackground.swift in Sources */,
236232
);
237233
runOnlyForDeploymentPostprocessing = 0;
238234
};
@@ -406,7 +402,7 @@
406402
PRODUCT_NAME = "$(TARGET_NAME)";
407403
SKIP_INSTALL = YES;
408404
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
409-
SWIFT_SWIFT3_OBJC_INFERENCE = On;
405+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
410406
SWIFT_VERSION = 4.0;
411407
};
412408
name = Debug;
@@ -428,7 +424,7 @@
428424
PRODUCT_BUNDLE_IDENTIFIER = com.wilsonding.SwiftVideoBackground;
429425
PRODUCT_NAME = "$(TARGET_NAME)";
430426
SKIP_INSTALL = YES;
431-
SWIFT_SWIFT3_OBJC_INFERENCE = On;
427+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
432428
SWIFT_VERSION = 4.0;
433429
};
434430
name = Release;

0 commit comments

Comments
 (0)