element-hq / element-x-ios

Next generation Matrix client for iOS built with SwiftUI on top of matrix-rust-sdk.
https://element.io/labs/element-x
GNU Affero General Public License v3.0
399 stars 87 forks source link

Disable locking during voice message playback / play in background #3197

Closed Jaffex closed 1 week ago

Jaffex commented 3 weeks ago

Is your feature request related to a problem? Please describe. Listening to voice messages longer than the auto locking cycle is very annoying. One has to either tap the screen during playback or resume playback when the voice message got paused by the phone auto locking.

Describe the solution you'd like When playing back a voice message, the phone could be prevented from locking, similar to how it does not lock while recording one.

Alternatively or even in addition (if one wants to lock the phone manually during playback), the voice message playback could also continue in the background, while the phone is locked.

Describe alternatives you've considered So far I've not found one, except just manually preventing the phone from locking. I did not want to increase the phone's locking time as it a) does not solve the problem for longer voice messages either and b) reduces security

Additional context (None)

stefanceriu commented 1 week ago

Came across this while implementing it, leaving it here for future reference https://developer.apple.com/library/archive/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionCategoriesandModes/AudioSessionCategoriesandModes.html#//apple_ref/doc/uid/TP40007875-CH10-SW3

stefanceriu commented 1 week ago

On the problem at hand, this seems to be completely intentional which is surprising and seems very weird to me. I'll go clean that code up and check everything works properly in the background.

https://github.com/element-hq/element-x-ios/blob/0f3b33c5ae3f9864197b20384e63286e4bfeb913/ElementX/Sources/Services/Audio/Player/AudioPlayer.swift#L222-L230

stefanceriu commented 1 week ago

Okay, #3236 will fix this as well as add playback controls on the lockscreen, do let us know if you have any more troubles with it.

Jaffex commented 1 week ago

Awesome, can't wait to try it out! Thank you Stefan for your awesome work on this app!