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.
File Location:
LMFeedVideoCollectionCell.swift
UI Components
videoPlayer: An instance ofLMFeedLoopedVideoPlayerresponsible for playing and looping the video.crossButton: An LMFeedButton that represents the cross button for removing the video.
Data Variables
crossButtonHeight: ACGFloatvalue 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 optionalURLobject representing the video URL.
Methods
configure(): Configures the cell with the providedContentModeldata and an optionalcrossButtonActionclosure.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 thevideoURLis set, unloads the video player, and executes thecrossButtonActionclosure 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
}