Szukam sposobu na wymuszenie, aby odtwarzacz AV (wideo) wyświetlał się tylko w trybie poziomym (przycisk home po lewej). czy to możliwe?Jak wymusić tryb pejzażu w AVPlayer?
EDIT: Próba dodać playerViewController.supportedInterfaceOrientations = .landscapeLeft
Got komunikat "Nie można przypisać właściwości: 'supportedInterfaceOrientations' to get-only property"
import AVKit
import AVFoundation
UIViewController {
var videoPlayer = AVPlayer()
var playerViewController = AVPlayerViewController()
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
play()
}
func play() {
playerViewController.supportedInterfaceOrientations = .landscapeLeft
let moviePath = Bundle.main.path(forResource: "full video", ofType: "mov")
if let path = moviePath {
let url = NSURL.fileURL(withPath: path)
let videoPlayer = AVPlayer(url: url)
let playerViewController = AVPlayerViewController()
playerViewController.player = videoPlayer
self.present(playerViewController, animated: true) {
if let validPlayer = playerViewController.player {
validPlayer.play()
playerViewController.showsPlaybackControls = false
}
}
}
}
}
EDIT: Próba dodać nową podklasę AVPlayerViewController
import UIKit
import AVFoundation
import AVKit
class LandscapeVideoControllerViewController: AVPlayerViewController {
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return .landscapeLeft
}
}
ale coraz komunikat o błędzie „Metoda nie zastępuje żadnej metody z nadklasy”
próbował dodać dziedziczone Obsługiwana właściwość orientacji interfejsu i otrzymała komunikat o błędzie "Nie można przypisać do właściwości:" supportedInterfaceOrientations "jest właściwością tylko do uzyskania" - wszelkie pomysły? –
ah tak, powinienem pamiętać, że przepraszam. Zaktualizowałem odpowiedź: – Scriptable
zredagowałem moje pytanie- stworzyłem nowy plik SWIFT i dodałem zastąpienie, ale z tym otrzymuję komunikat "Metoda nie zastępuje żadnej metody ze swojej nadklasy" i jeśli usunę nadpisanie, otrzymuję "Metoda supportedInterfaceOrientations() z selektorem obiektywu" supportedInterfaceOrientations "konflikty z getter dla" supportedInterfaceOrientations z nadklasy "UIViewController" z tym samym selektorem celu-c "- wszelkie pomysły? –