Skip to main content

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 of LMFeedLoopedVideoPlayer responsible for playing and looping the video.
  • crossButton: An LMButton that represents the cross button for removing the video.

Data Variables

  • crossButtonHeight: A CGFloat 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 optional URL object representing the video URL.

Methods

  • configure(): Configures the cell with the provided ContentModel data and an optional crossButtonAction 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 the videoURL is set, unloads the video player, and executes the crossButtonAction 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
}