Fix changing greyscale images preference breaking gifvs looping

This commit is contained in:
Shadowfacts 2024-03-31 20:51:28 -04:00
parent f0ec372f50
commit 08bd78d51b
1 changed files with 4 additions and 0 deletions

View File

@ -62,10 +62,14 @@ class GifvController {
@objc private func preferencesChanged() { @objc private func preferencesChanged() {
if isGrayscale != Preferences.shared.grayscaleImages { if isGrayscale != Preferences.shared.grayscaleImages {
isGrayscale = Preferences.shared.grayscaleImages isGrayscale = Preferences.shared.grayscaleImages
let oldItem = item
item = GifvController.createItem(asset: asset) item = GifvController.createItem(asset: asset)
player.replaceCurrentItem(with: item) player.replaceCurrentItem(with: item)
self.updatePresentationSizeObservation() self.updatePresentationSizeObservation()
player.play() player.play()
NotificationCenter.default.removeObserver(self, name: AVPlayerItem.didPlayToEndTimeNotification, object: oldItem)
NotificationCenter.default.addObserver(self, selector: #selector(restartItem), name: AVPlayerItem.didPlayToEndTimeNotification, object: item)
} }
} }