Now playing centre changes
This commit is contained in:
parent
5fe8c3b7cc
commit
cd4cb28ade
|
@ -236,7 +236,7 @@ class VideoPlayerViewController: UIViewController, VideoPlayerSettingsDelegate,
|
||||||
// If no default audio tracks select the first one
|
// If no default audio tracks select the first one
|
||||||
if selectedAudioTrack == -1 && !audioTrackArray.isEmpty{
|
if selectedAudioTrack == -1 && !audioTrackArray.isEmpty{
|
||||||
selectedAudioTrack = audioTrackArray.first!.id
|
selectedAudioTrack = audioTrackArray.first!.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
self.sendPlayReport()
|
self.sendPlayReport()
|
||||||
|
@ -291,6 +291,7 @@ class VideoPlayerViewController: UIViewController, VideoPlayerSettingsDelegate,
|
||||||
commandCenter.seekForwardCommand.isEnabled = true
|
commandCenter.seekForwardCommand.isEnabled = true
|
||||||
commandCenter.seekBackwardCommand.isEnabled = true
|
commandCenter.seekBackwardCommand.isEnabled = true
|
||||||
commandCenter.changePlaybackPositionCommand.isEnabled = true
|
commandCenter.changePlaybackPositionCommand.isEnabled = true
|
||||||
|
commandCenter.enableLanguageOptionCommand.isEnabled = true
|
||||||
|
|
||||||
// Add handler for Pause Command
|
// Add handler for Pause Command
|
||||||
commandCenter.pauseCommand.addTarget { _ in
|
commandCenter.pauseCommand.addTarget { _ in
|
||||||
|
@ -340,18 +341,58 @@ class VideoPlayerViewController: UIViewController, VideoPlayerSettingsDelegate,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// commandCenter.enableLanguageOptionCommand.addTarget { [weak self](remoteEvent) in
|
||||||
|
// guard let self = self else {return .commandFailed}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
MPNowPlayingInfoCenter.default().nowPlayingInfo = [
|
var runTicks = 0
|
||||||
MPMediaItemPropertyTitle: "TestVideo",
|
var playbackTicks = 0
|
||||||
MPNowPlayingInfoPropertyPlaybackRate : 1.0,
|
|
||||||
MPNowPlayingInfoPropertyMediaType : AVMediaType.video,
|
if let ticks = manifest.runTimeTicks {
|
||||||
MPMediaItemPropertyPlaybackDuration : manifest.runTimeTicks ?? 0 / 10_000_000,
|
runTicks = Int(ticks / 10_000_000)
|
||||||
MPNowPlayingInfoPropertyElapsedPlaybackTime : mediaPlayer.time.intValue/1000
|
}
|
||||||
]
|
|
||||||
|
if let ticks = manifest.userData?.playbackPositionTicks {
|
||||||
|
playbackTicks = Int(ticks / 10_000_000)
|
||||||
|
}
|
||||||
|
|
||||||
|
var nowPlayingInfo = [String: Any]()
|
||||||
|
|
||||||
|
nowPlayingInfo[MPMediaItemPropertyTitle] = manifest.name!
|
||||||
|
nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = 0.0
|
||||||
|
nowPlayingInfo[MPNowPlayingInfoPropertyMediaType] = AVMediaType.video
|
||||||
|
nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = runTicks
|
||||||
|
nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = playbackTicks
|
||||||
|
|
||||||
|
if let imageData = NSData(contentsOf: manifest.getPrimaryImage(maxWidth: 200)) {
|
||||||
|
let artworkImage = UIImage(data: imageData as Data)
|
||||||
|
nowPlayingInfo[MPMediaItemPropertyArtwork] = artworkImage
|
||||||
|
}
|
||||||
|
|
||||||
|
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
|
||||||
|
|
||||||
|
|
||||||
UIApplication.shared.beginReceivingRemoteControlEvents()
|
UIApplication.shared.beginReceivingRemoteControlEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateNowPlayingCenter(time : Double?, playing : Bool?) {
|
||||||
|
|
||||||
|
var nowPlayingInfo = MPNowPlayingInfoCenter.default().nowPlayingInfo ?? [String: Any]()
|
||||||
|
|
||||||
|
if let playing = playing {
|
||||||
|
nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = playing ? 1.0 : 0.0
|
||||||
|
}
|
||||||
|
if let time = time {
|
||||||
|
nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = time
|
||||||
|
}
|
||||||
|
|
||||||
|
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Grabs a refference to the info panel view controller
|
// Grabs a refference to the info panel view controller
|
||||||
|
@ -381,6 +422,8 @@ class VideoPlayerViewController: UIViewController, VideoPlayerSettingsDelegate,
|
||||||
|
|
||||||
self.sendProgressReport(eventName: "pause")
|
self.sendProgressReport(eventName: "pause")
|
||||||
|
|
||||||
|
self.updateNowPlayingCenter(time: nil, playing: false)
|
||||||
|
|
||||||
animateScrubber()
|
animateScrubber()
|
||||||
|
|
||||||
self.scrubLabel.frame = CGRect(x: self.scrubberView.frame.minX - self.scrubLabel.frame.width/2, y:self.scrubLabel.frame.minY, width: self.scrubLabel.frame.width, height: self.scrubLabel.frame.height)
|
self.scrubLabel.frame = CGRect(x: self.scrubberView.frame.minX - self.scrubLabel.frame.width/2, y:self.scrubLabel.frame.minY, width: self.scrubLabel.frame.width, height: self.scrubLabel.frame.height)
|
||||||
|
@ -390,6 +433,8 @@ class VideoPlayerViewController: UIViewController, VideoPlayerSettingsDelegate,
|
||||||
playing = true
|
playing = true
|
||||||
mediaPlayer.play()
|
mediaPlayer.play()
|
||||||
|
|
||||||
|
self.updateNowPlayingCenter(time: nil, playing: true)
|
||||||
|
|
||||||
self.sendProgressReport(eventName: "unpause")
|
self.sendProgressReport(eventName: "unpause")
|
||||||
|
|
||||||
animateScrubber()
|
animateScrubber()
|
||||||
|
@ -696,6 +741,7 @@ class VideoPlayerViewController: UIViewController, VideoPlayerSettingsDelegate,
|
||||||
activityIndicator.isHidden = true
|
activityIndicator.isHidden = true
|
||||||
activityIndicator.stopAnimating()
|
activityIndicator.stopAnimating()
|
||||||
}
|
}
|
||||||
|
updateNowPlayingCenter(time: nil, playing: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
let time = mediaPlayer.position
|
let time = mediaPlayer.position
|
||||||
|
|
Loading…
Reference in New Issue