Reputation: 7536
In my tvOS app I am playing an audio only stream, with no defined length. What I am finding is the time bar at the bottom of the screen display time indicators (at left and right) just flicker between 0:00 and the time that the stream has been playing for.
Two options I am looking at is either telling the AVPlayerViewController not to display the time or somehow masking the time bar, but not losing the audio menu at the top of the screen. Can anyone suggest an appropriate solution
I should note I have only tested this in the emulator, which is using tvOS 9.2.
The code I have at the moment:
class StreamPlayerViewController: AVPlayerViewController
var playerItem:AVPlayerItem?
var playerLayer:AVPlayerLayer?
override func viewDidLoad() {
let videoURL = NSURL(string: "http://example.org/aac.m3u")
playerItem = AVPlayerItem(URL: videoURL!)
self.player=AVPlayer(playerItem: playerItem!)
self.playerLayer=AVPlayerLayer(player: player)
self.player?.play()
}
// hides controller, but also lose access to audio menu
override func viewDidAppear(animated: Bool) {
self.playerLayer?.frame=self.view.frame
self.playerLayer?.backgroundColor=UIColor.blackColor().CGColor
self.view.layer.addSublayer(self.playerLayer!)
}
}
Upvotes: 0
Views: 214
Reputation: 7536
The solution I have for now is to extend AVPlayer and override the currentTime function:
class CustomAVPlayer : AVPlayer {
override func currentTime() -> CMTime {
return CMTime(value: 0, timescale: 60)
}
}
While this does not hide the time bar, it does ensure the time values stay at zero, while not preventing access to the playback settings.
Upvotes: 0