Video View
Overview
LMFeedVideoCollectionCell
is used to display a video player with an optional cross button for removing the video. This cell is typically used to display videos in a collection view or grid layout. This is used in displaying videos in Feed List, Post Detail, Post Creation and Post Edit Screens.
UI Components
videoPlayer
: An instance ofLMFeedLoopedVideoPlayer
responsible for playing and looping the video.crossButton
: AnLMButton
that represents the cross button for removing the video.
Data Variables
crossButtonHeight
: ACGFloat
value that determines the height of the cross button.crossButtonAction
: A closure that is executed when the cross button is tapped, passing the video URL as a parameter.videoURL
: An optionalURL
object representing the video URL.
Methods
configure()
: Configures the cell with the providedContentModel
data and an optionalcrossButtonAction
closure.playVideo()
: Starts playing the video.pauseVideo()
: Pauses the video playback.unload()
: Unloads and stops the video player.
Action Handlers
didTapCrossButton()
: The selector method for the cross button's tap action. It checks if thevideoURL
is set, unloads the video player, and executes thecrossButtonAction
closure if it's not nil, passing the video URL as a parameter.
Customization
CustomVideoCell.swift
class CustomVideoCell: LMFeedVideoCollectionCell {
override func setupAppearance() {
super.setupAppearance()
containerView.backgroundColor = .green
crossButton.tintColor = .white
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.videoPreview = CustomVideoCell.self
// ...
return true
}