SwiftVideoPhone

SwiftVideoBackground is an easy to use Swift framework that provides the ability to play videos on any UIView. This provides a nice user interface for the login screens or home pages of Spotify and many others.

Characteristics

  • x] Play the video with one line of code.
  • x] Supports local video and video from the web address.
  • x] Automatically adjusts when the orientation of the camera changes.
  • x] Resumes the video automatically when the application returns to the foreground.
  • x] Pause, resume, restart and other commands
  • x] Cycling videos (optional)
  • x] Mute (optional)
  • x] Dark videos to make the overlaid user interface more noticeable (optional).
  • x] Documentation

Integration

Cocoa beans

You can use CocoaPods to install SwiftVideoBackground by adding it to your podfile:

For Swift 5 :

SwiftVideo Phone Pod

For Swift 4 :

SwiftVideoBackground pod, ~> 3.0.

For Swift 3 :

SwiftVideoPhone pod, 0.06.

Carthago

You can use Carthage to install SwiftVideoBackground by adding it to the map file:

github dingwilson/SwiftVideoBackground

Manual

You can use this library manually in your project:

  1. For projects, simply drag VideoBackground.fast into the project tree.
  2. For workspaces, enter the full SwiftVideoBackground.xcodeproj file.

Migration Manual

Version 3.0.0

Version 2.0.0

See the quick migration guide.

Use

Example

UIKit
import SwiftVideoBackground

MyViewController class: UIViewController {
Override viewDidLoad() {
super.viewDidLoad()

Want to try it? VideoBackground.shared.play(view: display, videoName: myVideo, videoType: mp4)

/* or with a URL */

let url = URL(string : https://coolVids.com/coolVid.mp4) !
VideoBackground.shared.play(view : view, url : url)}

The documentation for version 0.06 (Swift 3) can be found here.

Setting

play() has four additional optional parameters that can be configured:

  • Darkness: CGFloat – Value between 0 and 1. The higher the value, the darker the video. The default value is 0.
  • muted : Bool – Indicates whether video is disabled. This is true by default.
  • WillLoopVideo : Bool – Indicates whether the video should be restarted when finished. This is true by default.
  • SetAudioSessionAmbient: Bool – Specifies whether the overall AVAudioSession should be set to ambient mode. Otherwise, the sound played by your application will interrupt the other sounds on the unit. This is true by default.

So, for example:

VideoBackground.shared.play(
view : view,
videoName : myVideo,
videoType : mp4,
darkness : 0.25,
isMuted : false,
willLoopVideo : true,
setAudioSessionAmbient : true
)

-> Plays the video with the sound, slightly muted, in a continuous loop and without affecting the other audio sources on the device.

Any combination of parameters can be enabled or disabled.

setAudioSessionAmbient is only valid on iOS 10.0+. Ask your doctors for more information.

Control

  • pause() – pauses the video.
  • resume() – Resume the video.
  • restart() – restarts the video.
  • getThumbnailImage(from: URL, at: CMTime) – Generates an image of a video to be displayed as a thumbnail.
  • Darkness – Change this CGFloat to adjust the darkness of the video. The value is between 0 and 1. The higher numbers are more dismal. Setting an invalid value has no effect.
  • isMuted – Change this bool to mute or unmute the video.
  • willLoopVideo – Change this bool to indicate whether the video should reload when it ends.
  • videoGravity – the default setting is .resizeAspectFill. Change to .resizeAspect (does not fill the view) or .sizeze (does not maintain the aspect ratio).
  • playerLayer – AVPlayerLayer which can be used for advanced video control and configuration.

Single socket

SwiftVideoBackground contains a single key instance that is easily accessible via VideoBackground.shared. A VideoBackground instance can only play one video at a time on a UIView. So, if you need to play on different UIViews, you need to save an instance of VideoBackground for each UIView:

let videoBackground1 = VideoBackground()

Add a video to your project

To play local videos, you must add them to your project:

  1. Open the project browser
  2. Choose your destination
  3. Select construction phases
  4. Select the package Copy Resources
  5. Press + to add a video

GitHub

add overlay to video swift + github,ios create video from images github,swiftui video background,custom video player in ios github,custom video player swift,avplayer play video in background,Privacy settings,How Search works,swifty360player,swift play video in background,play video in background ios swift,video background github

You May Also Like

Prevent Automatic Codec Download on Windows Media Player

Windows Media Player automatically loads codecs (short for decoder codecs or compressor…

23 Solutions To Fix Print Spooler Keeps Stopping In Windows 10

Printers are one of the most important devices you can own if…

How to choose cross-entropy loss function in Keras?

Inputs: 1) A model. It can be any Keras model. 2) An…

9 Solutions To Fix Avast Won’t Open In Windows 10

Wordbakers is a fun puzzle game that combines its content with a…