A swift and objective-C object that lets you add a background video to iOS views

Overview

BackgroundVideoiOS

This is an Object/Class which lets you add a background video to iOS app views. This is seen at login views of some famous apps like Spotify, tumbler and Vimeo

This is how they look..
##### It does the following: * *Creates an AVPlayer object for you and plays a video from your app bundle*
  • Handles video looping

  • Handles app going to background and coming back to foreground

  • Handles seguing away and back again to the view that plays the video

  • Mutes the video and does not allow it to interrupt other audio services. For example, it does not stop music playing from your music app or a VoIP call

Instructions for Swift:
  1. Have an awesome video that you want to show as your background

  2. Drag and drop BackgroundVideo.swift file to your Project navigator

  3. Drag and drop the video to your project and make sure to check Copy items if needed as well as Add to targets (This is because the object will look at your app's main bunddle)

  1. Go to the view controller where you want to display the video and declare an instance.

    	var backgroundPlayer : BackgroundVideo? // Declare an instance of BackgroundVideo called backgroundPlayer
  2. In your viewDidLoad() method, initialize your instance with the view controller you're using and the name of the video file with it's extension as parameters (make sure you seperate your name and extension by a period). In the following code I'm passing the same view controller where I declared my instance, namely self. Then, just call the function setUpBackground() on your instance.

 override func viewDidLoad() {
        super.viewDidLoad()
        // Initializing your instance 
        backgroundPlayer = BackgroundVideo(onViewController: self, withVideoURL: "test.mp4") // Passing self and video name with extension
        backgroundPlayer?.setUpBackground() 
    }
Instructions for Objective-C:
  1. Do steps 1-3 from the Swift steps above, but instead of dragging BackgroundVideo.swift, drag and drop BackgroundVideoObjC.h and BackgroundVideoObjC.m.

  2. Go to the view controller where you want to display the video and declare an instance.

    	@property (strong, nonatomic) BackgroundVideoObjC *backgroundVideo;
  3. Same as 5 from Swift steps, except use this code:

- (void)viewDidLoad {
    self.backgroundVideo = [[BackgroundVideoObjC alloc] initOnViewController:self withVideoURL:@"test.mp4"];
    [self.backgroundVideo setUpBackground];
}
That's it, you're ready to go :)!
You might also like...
Placeholder views based on content, loading, error or empty states
Placeholder views based on content, loading, error or empty states

StatefulViewController A protocol to enable UIViewControllers or UIViews to present placeholder views based on content, loading, error or empty states

Zeplin component preview for your SwiftUI views
Zeplin component preview for your SwiftUI views

A Zeplin component preview for your SwiftUI views. You can use Zeplin components instead of real views within your app until you implement them.

A SwiftUI Views for wrapping HStack elements into multiple lines
A SwiftUI Views for wrapping HStack elements into multiple lines

SwiftUI WrappingStack A SwiftUI Views for wrapping HStack elements into multiple lines. List of supported views WrappingHStack - provides HStack that

Create SwiftUI Views with any data

Create SwiftUI Views with any data

Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements
Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements

SwiftUIKitView Easily use UIKit views in SwiftUI. Convert UIView to SwiftUI View Create Xcode Previews from UIView elements SwiftUI functional updatin

Compose views using enums swiftly: `let label: UILabel = [.text("Hello"), .textColor(.red)]`

ViewComposer Style views using an enum array with its attributes: let label: UILabel = [.text("Hello World"), .textColor(.red)] Table of Contents Inst

A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.

LoadingShimmer An easy way to add a shimmering effect to any view with just single line of code. It is useful as an unobtrusive loading indicator. Thi

⚙ Add a preferences window to your macOS app in minutes
⚙ Add a preferences window to your macOS app in minutes

Preferences Add a preferences window to your macOS app in minutes Just pass in some view controllers and this package will take care of the rest. Requ

Comments
  • Adding 2 videos to the same project

    Adding 2 videos to the same project

    I have in my project 2 viewControllers with 2 different background videos. The first video is 12 seconds long and the second video is 2 seconds long.

    When I only enable the first video in my project it loops perfect after 12 seconds. But when I also enables the 2nd video, on another viewController, the first videos timer get messed up. The first video loops after 2 seconds?

    It seems like the first video inherit the 2nd videos length (2 seconds instead of 12) ? No idea why this is occurring? And I am using the videos on different viewControllers in my project.

    This is how I setup the videos by code:

    viewController 1:

    • (void)viewDidLoad { [self setBackgroundVideo: [[BackgroundVideo alloc] initOnViewController:self withVideoURL:@"landingVideo.mp4"]];

      [backgroundVideo setUpBackground]; }

    viewController 2:

    • (void)viewDidLoad { [self setBackgroundVideo: [[BackgroundVideo alloc] initOnViewController:self withVideoURL:@"IntroSplash.mp4"]];

      [backgroundVideo setUpBackground]; }

    opened by jeppsim 0
Owner
Amro Gazlan
Computer engineer
Amro Gazlan
Confetti View lets you create a magnificent confetti view in your app

ConfettiView Confetti View lets you create a magnificent confetti view in your app. This was inspired by House Party app's login screen. Written in Sw

Or Ron 234 Nov 22, 2022
URLEmbeddedView automatically caches the object that is confirmed the Open Graph Protocol.

URLEmbeddedView Features Simple interface for fetching Open Graph Data Be able to display Open Graph Data Automatically caching Open Graph Data Automa

Taiki Suzuki 643 Dec 20, 2022
A flexible container view featuring a solid background with rounded corners.

A flexible container view featuring a solid background with rounded corners.

Tim Oliver 13 Jan 22, 2022
Creating a blurred window background in Mac Catalyst

TransparentChrome In response to a developer question, I looked for the easiest way to provide a translucent full-window chrome with a blurred backgro

Steven Troughton-Smith 37 Dec 2, 2022
DrawerKit lets an UIViewController modally present another UIViewController in a manner similar to the way Apple's Maps app works.

DrawerKit What is DrawerKit? DrawerKit is a custom view controller presentation mimicking the kind of behaviour in the Apple Maps app. It lets any vie

Babylon Health 773 Dec 27, 2022
🏞 A simple iOS photo and video browser with optional grid view, captions and selections written in Swift5.0

Introduction ?? MediaBrowser can display one or more images or videos by providing either UIImage objects, PHAsset objects, or URLs to library assets,

Kyle Yi 631 Dec 29, 2022
Runtime introspection and unit testing of SwiftUI views

ViewInspector is a library for unit testing SwiftUI views. It allows for traversing a view hierarchy at runtime providing direct access to the underlying View structs.

Alexey Naumov 1.5k Jan 2, 2023
Easily add drop shadows, borders, and round corners to a UIView.

Easily add drop shadows, borders, rounded corners to a UIView. Installation CocoaPods Add the follwing to your Podfile: pod 'Shades' Usage Storyboard

Aaron Sutton 14 Jun 20, 2020
Redesigned video player controls for iOS

Atlas Minimal stock video player replacement demo video Compiling Clone the repo, and make sure you have cephei and all that then just make clean pack

Chr1s 15 Feb 19, 2022
Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.

kishikawakatsumi/SpreadsheetView has moved! It is being actively maintained at bannzai/SpreadsheetView. This fork was created when the project was mov

Kishikawa Katsumi 34 Sep 26, 2022