//
//  PlayDetailViewController+Ext.swift
//  ColorfulWallpaper
//
//  Created by ni on 2024/9/18.
//

import Foundation
import SJVideoPlayer

extension PlayDetailViewController: SJProgressSliderDelegate {
    func sliderWillBeginDragging(_ slider: SJProgressSlider) {
        playControl.pause()
    }

    func slider(_ slider: SJProgressSlider, valueDidChange value: CGFloat) {
        
        let durationTime = playControl.player.duration
        let currentTime = durationTime * value
        controlView.updateTime(currentTime: currentTime, duration: durationTime)
    }

    func sliderDidEndDragging(_ slider: SJProgressSlider) {
        playControl.seekToProgress(progress: slider.value) { _ in
            self.playControl.play()
        }
        
    }
}
