Skip to content

Commit

Permalink
Merge pull request #13 from quanvo87/master
Browse files Browse the repository at this point in the history
2.0.0
  • Loading branch information
dingwilson authored Dec 14, 2017
2 parents 9c7c24e + 8785613 commit 51a0b9c
Show file tree
Hide file tree
Showing 27 changed files with 911 additions and 554 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
build/
xcuserdata/
Binary file added Assets/add-video-to-project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## [2.0.0](https://github.com/dingwilson/SwiftVideoBackground/tree/2.0.0) (2017-12-14)
**Major Release: BREAKING CHANGES**
- renamed class from `BackgroundVideo` to `VideoBackground` for consistency with package name
- class is no longer a subclass of `UIView`
- instantiate an instance simply with `let videoBackground = VideoBackground()`
- 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`.

For more information, please see the [documentation](http://wilsonding.com/SwiftVideoBackground/)

For an example and help with migrating from previous verisons, please see the [migration guide](migration-2.0.0.md)

## [1.0.1](https://github.com/dingwilson/SwiftVideoBackground/tree/1.0.1) (2017-10-31)
- Modified minimum deployment target to iOS 8.0

Expand Down
86 changes: 86 additions & 0 deletions README-0.06.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<p align="center">
<img src="Assets/banner.png" width="780" title="SwiftVideoBackground">
</p>

[![CocoaPods Version Status](https://img.shields.io/cocoapods/v/SwiftVideoBackground.svg)][podLink]
[![Carthage compatible](https://img.shields.io/badge/Carthage-Compatible-brightgreen.svg?style=flat)](https://github.com/Carthage/Carthage)
[![CocoaPods](https://img.shields.io/cocoapods/dt/SwiftVideoBackground.svg)](https://cocoapods.org/pods/SwiftVideoBackground)
[![CocoaPods](https://img.shields.io/cocoapods/dm/SwiftVideoBackground.svg)](https://cocoapods.org/pods/SwiftVideoBackground)
![Platform](https://img.shields.io/badge/platforms-iOS-333333.svg)
[![Swift](https://img.shields.io/badge/Swift-3.0+-orange.svg)](https://swift.org)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)][mitLink]

<p align="center">
<img src="Assets/Spotify.gif" width="369" title="Screenshot">
</p>

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.

1. [Requirements](#requirements)
2. [Integration](#integration)
- [Cocoapods](#cocoapods)
- [Carthage](#carthage)
- [Manually](#manually)
3. [Usage](#usage)
4. [License](#license)

## Requirements

- Swift 3+
- iOS 8+

## Integration

#### CocoaPods
You can use [CocoaPods](http://cocoapods.org/) to install `SwiftVideoBackground` by adding it to your `Podfile`:

For Swift 3:
```ruby
pod 'SwiftVideoBackground', '~> 0.06'
```

#### Carthage
You can use [Carthage](https://github.com/Carthage/Carthage) to install `SwiftVideoBackground` by adding it to your `Cartfile`:
```
github "dingwilson/SwiftVideoBackground"
```

#### Manually

To use this library in your project manually you may:

1. for Projects, just drag BackgroundVideo.swift to the project tree
2. for Workspaces, include the whole SwiftVideoBackground.xcodeproj

## Usage

Import the framework into the ViewController
```swift
import SwiftVideoBackground
```

Link a UIView within a ViewController within the Storyboard to a BackgroundVideo item, or link it programmatically.
```swift
var backgroundVideo : BackgroundVideo!
```

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.
```swift
backgroundVideo.createBackgroundVideo(name: "Background", type: "mp4")
```
```swift
backgroundVideo.createBackgroundVideo(name: "Background", type: "mp4", alpha: 0.5)
```

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.

## License

`SwiftVideoBackground` is released under an [MIT License][mitLink]. See `LICENSE` for details.

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

*Please provide attribution, it is greatly appreciated.*

[podLink]:https://cocoapods.org/pods/SwiftVideoBackground
[mitLink]:http://opensource.org/licenses/MIT
89 changes: 63 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@
<img src="Assets/Spotify.gif" width="369" title="Screenshot">
</p>

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.
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.

1. [Requirements](#requrements)
1. [Requirements](#requirements)
2. [Integration](#integration)
- [Cocoapods](#cocoapods)
- [CocoaPods](#cocoapods)
- [Carthage](#carthage)
- [Manually](#manually)
3. [Usage](#usage)
4. [License](#license)
3. [Migration Guide](#migration-guide)
4. [Usage](#usage)
5. [License](#license)
6. [Authors](#authors)

## Requirements

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

For Swift 4:
```ruby
pod 'SwiftVideoBackground'
pod 'SwiftVideoBackground', '~> 2.0.0'
```

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

To use this library in your project manually you may:

1. for Projects, just drag BackgroundVideo.swift to the project tree
1. for Projects, just drag VideoBackground.swift to the project tree
2. for Workspaces, include the whole SwiftVideoBackground.xcodeproj

## Migration Guide

Version 2.0.0 brings improvements and breaking changes. See the quick migration guide [here](migration-2.0.0.md).

## Usage

Import the framework into the ViewController
```swift
import SwiftVideoBackground
```
#### Example

Link a UIView within a ViewController within the Storyboard to a BackgroundVideo item, or link it programmatically.
```swift
var backgroundVideo : BackgroundVideo!
```
``` swift
import UIKit
import VideoBackground

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.
```swift
backgroundVideo.createBackgroundVideo(name: "Background", type: "mp4")
```
```swift
backgroundVideo.createBackgroundVideo(name: "Background", type: "mp4", alpha: 0.5)
class MyViewController: UIViewController {
private let videoBackground = VideoBackground()

override func viewDidLoad() {
super.viewDidLoad()

videoBackground.play(view: view, videoName: "myvideo", videoType: "mp4")
}
}
```

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.
> Documentation for Version 0.06 (Swift 3) can be found [here](README-0.06.md).
#### Customization Options

`play()` has three additional optional parameters for customization:
- `isMuted`: Bool - Indicates whether video is muted. Defaults to `true`.
- `alpha`: CGFloat - Value between 0 and 1. The higher the value, the darker the video. Defaults to `0`.
- `willLoopVideo`: Bool - Indicates whether video should restart when finished. Defaults to `true`.

To mute the video, simply set `isMuted` to true.
```swift
backgroundVideo.isMuted = true
So for example:

``` swift
videoBackground.play(view: view,
videoName: "myvideo",
videoType: "mp4",
isMuted: false,
alpha: 0.25,
willLoopVideo: true)
```

-> will play the video with the sound on, slightly darkened, and will continuously loop.

> Any combination of the three can be included or left out.
#### Adding Videos To Your Project

You must properly add videos to your project in order to play them. To do this:
1. Open your project navigator
2. Select your target
3. Select `Build Phases`
4. Select `Copy Bundle Resources`
5. Click `+` to add a video

![add video to project](Assets/add-video-to-project.png "add video to project")

## License

`SwiftVideoBackground` is released under an [MIT License][mitLink]. See `LICENSE` for details.
`SwiftVideoBackground` is released under an [MIT License][mitLink]. See [LICENSE](LICENSE) for details.

## Authors

[Wilson Ding](https://github.com/dingwilson), [Quan Vo](https://github.com/quanvo87)

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

Expand Down
9 changes: 5 additions & 4 deletions SwiftVideoBackground.podspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Pod::Spec.new do |s|
s.name = "SwiftVideoBackground"
s.version = "1.0.1"
s.version = "2.0.0"
s.summary = "An easy to use Swift framework that creates a video background for any ViewController."
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"
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"
s.homepage = "https://github.com/dingwilson/SwiftVideoBackground"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "Wilson Ding" => "[email protected]" }
s.author = { "Wilson Ding" => "[email protected]",
"Quan Vo" => "[email protected]" }
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/dingwilson/SwiftVideoBackground.git", :tag => "1.0.1" }
s.source = { :git => "https://github.com/dingwilson/SwiftVideoBackground.git", :tag => "2.0.0" }
s.source_files = "SwiftVideoBackground", "SwiftVideoBackground/**/*.{h,m,swift}"
s.exclude_files = "Classes/Exclude"
end
16 changes: 6 additions & 10 deletions SwiftVideoBackground.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
/* Begin PBXBuildFile section */
C82AAF8B1D9C1C4800A13307 /* SwiftVideoBackgroundTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C82AAF8A1D9C1C4800A13307 /* SwiftVideoBackgroundTests.swift */; };
C82AAF8D1D9C1C4800A13307 /* SwiftVideoBackground.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8D0633E1D99B62E006A5F00 /* SwiftVideoBackground.framework */; };
C87103D91FA2380600F817BC /* BackgroundVideoError.swift in Sources */ = {isa = PBXBuildFile; fileRef = C87103D81FA2380600F817BC /* BackgroundVideoError.swift */; };
C8D063431D99B62E006A5F00 /* SwiftVideoBackground.h in Headers */ = {isa = PBXBuildFile; fileRef = C8D063411D99B62E006A5F00 /* SwiftVideoBackground.h */; settings = {ATTRIBUTES = (Public, ); }; };
C8D0634A1D99B639006A5F00 /* BackgroundVideo.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8D063491D99B639006A5F00 /* BackgroundVideo.swift */; };
C8D0634A1D99B639006A5F00 /* VideoBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8D063491D99B639006A5F00 /* VideoBackground.swift */; };
/* End PBXBuildFile section */

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

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -84,8 +82,7 @@
C8D063401D99B62E006A5F00 /* SwiftVideoBackground */ = {
isa = PBXGroup;
children = (
C8D063491D99B639006A5F00 /* BackgroundVideo.swift */,
C87103D81FA2380600F817BC /* BackgroundVideoError.swift */,
C8D063491D99B639006A5F00 /* VideoBackground.swift */,
C8D063411D99B62E006A5F00 /* SwiftVideoBackground.h */,
C8D063421D99B62E006A5F00 /* Info.plist */,
);
Expand Down Expand Up @@ -231,8 +228,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C87103D91FA2380600F817BC /* BackgroundVideoError.swift in Sources */,
C8D0634A1D99B639006A5F00 /* BackgroundVideo.swift in Sources */,
C8D0634A1D99B639006A5F00 /* VideoBackground.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -406,7 +402,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
Expand All @@ -428,7 +424,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.wilsonding.SwiftVideoBackground;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
Expand Down
Loading

0 comments on commit 51a0b9c

Please sign in to comment.