Saturday, May 10, 2025
Alternative Way
  • Home
  • Latest
    • Latest
  • News
  • World Tech
  • World Gaming
  • Minecraft
  • Guides
  • Contact Us
  • About The Team
    • Privacy Policy
    • Terms of Use
No Result
View All Result
  • Home
  • Latest
    • Latest
  • News
  • World Tech
  • World Gaming
  • Minecraft
  • Guides
  • Contact Us
  • About The Team
    • Privacy Policy
    • Terms of Use
No Result
View All Result
Alternative Way
No Result
View All Result

Framework to Play a Video in the Background of any UIView

Gordon James by Gordon James
October 3, 2021
in World Tech Code
0 0
0
Home World Tech Code

Table of Contents

Toggle
  • SwiftVideoPhone
  • Characteristics
  • Integration
      • Cocoa beans
      • Carthago
      • Manual
  • Migration Manual
      • Version 3.0.0
      • Version 2.0.0
  • Use
      • Example
      • Setting
      • Control
      • Single socket
      • Add a video to your project
  • GitHub
      • Related Tags:

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

Framework to Play a Video in the Background of any UIView

GitHub

Related Tags:

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

Total
0
Shares
Share 0
Tweet 0
Pin it 0
Share 0
ShareTweet
Gordon James

Gordon James

Next Post
Best Alternatives for Viber on Apple Watch

Best Alternatives for Viber on Apple Watch

  • Trending
  • Comments
  • Latest
How To Get Free Internet On Android Without Service

How To Get Free Internet On Android Without Service

March 10, 2022
🥇 +4 Neo Geo Emulators for Android  List ▷ 2021

🥇 +4 Neo Geo Emulators for Android  List ▷ 2021

October 3, 2021

Fix: Notifications not working on Nova Launcher

October 3, 2021
How to Fix OpenVPN Connected but Not Changing IP Address

How to Fix OpenVPN Connected but Not Changing IP Address

October 3, 2021

Setting Up Directory Sync Between On-Premises Active Directory with Microsoft 365 Azure AD

0
🥇 DELETE ACCOUNT from PS4  ▷ Step by Step Guide ▷ 2020

🥇 DELETE ACCOUNT from PS4  ▷ Step by Step Guide ▷ 2020

0
🥇 PPTX File Extension  What is .Pptx and how to open them? ▷ 2020

🥇 PPTX File Extension  What is .Pptx and how to open them? ▷ 2020

0
🥇 Make a Crossword in Microsoft Word  Step by Step Guide ▷ 2020

🥇 Make a Crossword in Microsoft Word  Step by Step Guide ▷ 2020

0
What to Know About Car Shipping Services

What to Know About Car Shipping Services

May 7, 2025
CS2 Skins-Why Trade Them?

CS2 Skins-Why Trade Them?

May 7, 2025
Alternative Routes: Successfully Exiting Your Wyndham Timeshare Without The Stress

Alternative Routes: Successfully Exiting Your Wyndham Timeshare Without The Stress

May 6, 2025
The Ultimate Seiko Watch Gift Guide

The Ultimate Seiko Watch Gift Guide

May 1, 2025

There's always an alternative Way!
Find us at 4145 Zolynthian Street, Vylorthos, QP 78425
No Result
View All Result
  • Home
  • Latest
    • Latest
  • News
  • World Tech
  • World Gaming
  • Minecraft
  • Guides
  • Contact Us
  • About The Team
    • Privacy Policy
    • Terms of Use

© 2022 - Alternative Way

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT
No Result
View All Result
  • Home
    • Home – Layout 1
    • Home – Layout 2
    • Home – Layout 3
    • Home – Layout 4
    • Home – Layout 5
  • Travel News

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.