ashish0309 / AutoVideoPlayer

Easily Play/Pause videos in any UIView subclass especially UITableViewCell subclass
MIT License
101 stars 16 forks source link

Video Still Playing when screen is disappear. #8

Open YogeshPateliOS opened 4 years ago

YogeshPateliOS commented 4 years ago

Hello pausePlayeVideos method not working. I check with DisAppear Method as well.

YogeshPateliOS commented 4 years ago

For remove player add this code ASVideoPlayerController class. hope it's helpful for you.

    func removePlayer(tableView: UITableView){
        let visisbleCells = tableView.visibleCells
        var maxHeight: CGFloat = 0.0
        for cellView in visisbleCells {
            guard let containerCell = cellView as? ASAutoPlayVideoLayerContainer,
                let videoCellURL = containerCell.videoURL else {
                    continue
            }
            let height = containerCell.visibleVideoHeight()
            if maxHeight < height {
                maxHeight = height
            }
            pauseRemoveLayer(layer: containerCell.videoLayer, url: videoCellURL, layerHeight: height)
        }
    }
JolChrSA commented 4 years ago

@YogeshPateliOS Can you give a solution for Video in the First cell is not playing when it appears the first time, we have to drag its bottom slightly to play the video.

Plz, help me with that. Thanks in advance.

pratikgajbhiye222 commented 4 years ago

For remove player add this code ASVideoPlayerController class. hope it's helpful for you.

    func removePlayer(tableView: UITableView){
        let visisbleCells = tableView.visibleCells
        var maxHeight: CGFloat = 0.0
        for cellView in visisbleCells {
            guard let containerCell = cellView as? ASAutoPlayVideoLayerContainer,
                let videoCellURL = containerCell.videoURL else {
                    continue
            }
            let height = containerCell.visibleVideoHeight()
            if maxHeight < height {
                maxHeight = height
            }
            pauseRemoveLayer(layer: containerCell.videoLayer, url: videoCellURL, layerHeight: height)
        }
    }

ty