Post

Replies

Boosts

Views

Activity

Reply to AVFoundation player.publisher().assign() for @Observable/@ObservationTracked?
Hi Quinn, thanks for the insight! The reason for deviating from the approach in the link was to explore some of the new features with @Observable and converting projects which previously used ObservableObjects. It seems that most classes can be converted quite easily, but this is a case where it takes a deeper understanding to adjust to the new approach. I am new to all this (AVPlayer, Observable, Concurrency), but the solution I ended up implementing to represent Play state is to just look at the rate and return a bool, since AVPlayer just adjust the rate from 0.0 / (> 0.0) to Pause/Play. .receive(on: DispatchQueue.main) .sink { [weak self] rate in Logger.funcUpdate("Rate changed to: \(rate)") if rate == 0 { self?.isPlaying = false } else { self?.isPlaying = true } } .store(in: &subscriptions)
Dec ’23