VideoBackground
public class VideoBackground
Class that plays a video on a UIView.
-
Singleton instance that can be used to play a video.
Declaration
Swift
public static let shared = VideoBackground()
-
Initializes a VideoBackground instance.
Declaration
Swift
public init()
-
Plays a video on a UIView.
Declaration
Swift
public func play(view: UIView, videoName: String, videoType: String, isMuted: Bool = true, alpha: CGFloat = 0, willLoopVideo: Bool = true)
Parameters
view
UIView that the video will be played on.
videoName
String name of video that you have added to your project.
videoType
String type of the video. e.g.
mp4
isMuted
Bool indicating whether video is muted. Defaults to true.
alpha
CGFloat between 0 and 1. The higher the value, the darker the video. Defaults to 0.
willLoopVideo
Bool indicating whether video should restart when finished. Defaults to true.
-
Plays a video on a UIView.
Throws
VideoBackgroundError.videoNotFound
if the video cannot be found.Declaration
Swift
public func play(view: UIView, name: String, type: String, isMuted: Bool = true, alpha: CGFloat = 0, willLoopVideo: Bool = true) throws
Parameters
view
UIView that the video will be played on.
name
String name of video that you have added to your project.
type
String type of the video. e.g.
mp4
isMuted
Bool indicating whether video is muted. Defaults to true.
alpha
CGFloat between 0 and 1. The higher the value, the darker the video. Defaults to 0.
willLoopVideo
Bool indicating whether video should restart when finished. Defaults to true.
-
Plays videos one after another on a UIView.
Throws
VideoBackgroundError.videoNotFound
if a video cannot be found.Declaration
Swift
public func play(view: UIView, videoInfos: [VideoInfo], isMuted: Bool = true, alpha: CGFloat = 0, willLoopVideo: Bool = true) throws
Parameters
view
UIView that the video will be played on.
videoInfos
Array of
VideoInfo
for the videos to be played.isMuted
Bool indicating whether video is muted. Defaults to true.
alpha
CGFloat between 0 and 1. The higher the value, the darker the video. Defaults to 0.
willLoopVideo
Bool indicating whether video should restart when finished. Defaults to true.