Git Product home page Git Product logo

backgroundvideoios's Introduction

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

<img align="center" src="Screenshots/VimeoGif.gif"width="32%" height="auto">

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)

  4. 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
  5. 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 :)!

backgroundvideoios's People

Contributors

guzlan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.