Add media player notification widget and allow background playback#6440
Add media player notification widget and allow background playback#6440bxdxnn wants to merge 1 commit intoelement-hq:developfrom
Conversation
|
Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:
|
2187408 to
3f2fb7c
Compare
|
@bmarty FYI, this was done almost fully by LLM |
|
Thanks for the PR. I am not sure if we want to have such feature in the application. Can you post a video demoing it so I can ask the product team? Thanks |
Hello, I can't make a demo video as there are some technical bugs and minor design questions regarding the metadata in the notification since the last rebase, but I can continue if the main behavior will be accepted by the product team.
If this feature won't be accepted, can we allow background playback at least just when the app goes background? It'll be also great to be able to listen to media while you're in the app and the player is hidden, similar to Telegram, but this leads to the need of this feature because there would be no player controls without this PR. |
|
Thanks for your reply. We are building a messaging application and not a media player. The application is able to play media (video, voice message) when in the foreground as a facility, but I believe that users expect all media playing to just stop when the app is put into background. But I let @mxandreas give the final words here. |
|
I have checked the behavior on WhatsApp and Signal, and they do continue playing whatever was playing when you lock the screen or switch to another app, but they stop once the current file is finished. Thus, this as a behavior is fine as long as it can be done with what the OS/system provides and we do not need to design for any of the audio players, etc. I am curious though to understand in which situations are you @bxdxnn seeing this as a friction personally - what are you listening to, why is it challenging to keep the app in the foreground, etc. And in particular why would you even like to continue with the next/previous file in the timeline? Also, for the next PRs which are about new features (visual or not), please open a a Enhancement Request issue in the https://github.com/element-hq/element-meta/issues repo - describing the the use case and the why behind the feature. This way you can get feedback earlier if/what can we have in the product before we start reviewing the code which is always more effort. |
Do you want me to only implement the background widget (allowing background playback), without any other behavioral/UI changes to the app (cover arts, metadata, automatic forward/previous while in background, etc.)?
I want to create a read-only channel in a space where I publish my (~1 hour duration) audio books. Continuing it makes more convenient to listen to all medias in the room.
|
We should have a wake lock when playing media to mitigate this. I though we had one, but it's apparently not the case. |
|
The widget has an ability to show the cover art, but what should be shown when there's no cover art for an audio?
|
Good point, @bmarty. Do you have any strong arguments for "wake lock" vs "continue in the background" for this scenario?
I'd say the first iteration would be fine probably without anything, but if it easy to make, then probably sender's avatar. @americanrefugee do you agree? |
Yes, that's fine with me. |
I have to correct myself regarding this, in fact they continue playing, but there are some differences in behaviour, see details in #6454 (comment) |
3f2fb7c to
4743ebd
Compare
Media playback stops when the app goes to background because MediaVideoView and MediaAudioView explicitly pause/release ExoPlayer on lifecycle events. This adds a MediaSessionService that owns the ExoPlayer so playback survives backgrounding. Voice messages remain completely unaffected. Co-Authored-By: svetoslav.mitov <svetoslav.mitov@sportinno.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4743ebd to
8407516
Compare
|
I have removed the playlist (play next timeline media after ending) feature and the notification now uses sender's avatar for the cover art, addressing the product's decision review. Waiting for code review now. About WA/Signal behavior: I'm not sure what it means here, auto-playing voice messages is a different case from auto playing media or playing it in background. |

Content
Add a MediaStyle notification for the media player and allow background playback
Motivation and context
Media playback stops when the app goes to background because MediaVideoView and MediaAudioView explicitly pause/release ExoPlayer on lifecycle events. This adds a MediaSessionService that owns the ExoPlayer so playback survives backgrounding.
Screenshots / GIFs
Tests
Tested devices
Checklist