mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-20 08:02:16 +00:00
parent
2a2fafd03f
commit
839970fe2b
1 changed files with 12 additions and 34 deletions
|
|
@ -138,9 +138,6 @@ class CustomMediaPlayerViewController: UIViewController {
|
|||
private var volumeValue: Double = 0.0
|
||||
private var volumeViewModel = VolumeViewModel()
|
||||
var volumeSliderHostingView: UIView?
|
||||
|
||||
private let rotationDuration: Double = 0.3
|
||||
private let hapticFeedback = UIImpactFeedbackGenerator(style: .medium)
|
||||
|
||||
|
||||
init(module: ScrapingModule,
|
||||
|
|
@ -247,6 +244,11 @@ class CustomMediaPlayerViewController: UIViewController {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if #available(iOS 16.0, *) {
|
||||
playerViewController.allowsVideoFrameAnalysis = false
|
||||
}
|
||||
|
||||
player.play()
|
||||
|
||||
if let url = subtitlesURL, !url.isEmpty {
|
||||
|
|
@ -303,7 +305,10 @@ class CustomMediaPlayerViewController: UIViewController {
|
|||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(playerItemDidChange), name: .AVPlayerItemNewAccessLogEntry, object: nil)
|
||||
NotificationCenter.default.addObserver(self,
|
||||
selector: #selector(playerItemDidChange),
|
||||
name: .AVPlayerItemNewAccessLogEntry,
|
||||
object: nil)
|
||||
|
||||
skip85Button?.isHidden = !isSkip85Visible
|
||||
}
|
||||
|
|
@ -1137,17 +1142,6 @@ class CustomMediaPlayerViewController: UIViewController {
|
|||
}
|
||||
|
||||
@objc func seekBackward() {
|
||||
hapticFeedback.impactOccurred()
|
||||
self.backwardButton.transform = .identity
|
||||
|
||||
UIView.animate(withDuration: rotationDuration, delay: 0, options: [.curveLinear, .beginFromCurrentState]) {
|
||||
self.backwardButton.transform = CGAffineTransform(rotationAngle: -.pi * 2)
|
||||
} completion: { finished in
|
||||
if finished {
|
||||
self.backwardButton.transform = .identity
|
||||
}
|
||||
}
|
||||
|
||||
let skipValue = UserDefaults.standard.double(forKey: "skipIncrement")
|
||||
let finalSkip = skipValue > 0 ? skipValue : 10
|
||||
currentTimeVal = max(currentTimeVal - finalSkip, 0)
|
||||
|
|
@ -1158,17 +1152,6 @@ class CustomMediaPlayerViewController: UIViewController {
|
|||
}
|
||||
|
||||
@objc func seekForward() {
|
||||
hapticFeedback.impactOccurred()
|
||||
self.forwardButton.transform = .identity
|
||||
|
||||
UIView.animate(withDuration: rotationDuration, delay: 0, options: [.curveLinear, .beginFromCurrentState]) {
|
||||
self.forwardButton.transform = CGAffineTransform(rotationAngle: .pi * 2)
|
||||
} completion: { finished in
|
||||
if finished {
|
||||
self.forwardButton.transform = .identity
|
||||
}
|
||||
}
|
||||
|
||||
let skipValue = UserDefaults.standard.double(forKey: "skipIncrement")
|
||||
let finalSkip = skipValue > 0 ? skipValue : 10
|
||||
currentTimeVal = min(currentTimeVal + finalSkip, duration)
|
||||
|
|
@ -1177,6 +1160,7 @@ class CustomMediaPlayerViewController: UIViewController {
|
|||
self.updateBufferValue()
|
||||
}
|
||||
}
|
||||
|
||||
@objc func handleDoubleTap(_ gesture: UITapGestureRecognizer) {
|
||||
let tapLocation = gesture.location(in: view)
|
||||
if tapLocation.x < view.bounds.width / 2 {
|
||||
|
|
@ -1193,14 +1177,10 @@ class CustomMediaPlayerViewController: UIViewController {
|
|||
}
|
||||
|
||||
@objc func togglePlayPause() {
|
||||
hapticFeedback.impactOccurred()
|
||||
|
||||
if isPlaying {
|
||||
player.pause()
|
||||
isPlaying = false
|
||||
UIView.transition(with: playPauseButton, duration: 0.2, options: .transitionCrossDissolve) {
|
||||
self.playPauseButton.image = UIImage(systemName: "play.fill")
|
||||
}
|
||||
playPauseButton.image = UIImage(systemName: "play.fill")
|
||||
|
||||
if !isControlsVisible {
|
||||
isControlsVisible = true
|
||||
|
|
@ -1213,9 +1193,7 @@ class CustomMediaPlayerViewController: UIViewController {
|
|||
} else {
|
||||
player.play()
|
||||
isPlaying = true
|
||||
UIView.transition(with: playPauseButton, duration: 0.2, options: .transitionCrossDissolve) {
|
||||
self.playPauseButton.image = UIImage(systemName: "pause.fill")
|
||||
}
|
||||
playPauseButton.image = UIImage(systemName: "pause.fill")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue