Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the now playing info center while a voice broadcast is played #7257

Merged
merged 6 commits into from
Jan 17, 2023

Conversation

nimau
Copy link
Contributor

@nimau nimau commented Jan 10, 2023

This PR fixes the display in the Now Playing Info Center (NPIC) when a user is listening to a voice broadcast.
The NPIC was showing a voice message instead of a voice broadcast.

To test:

  • Listen to a voice broadcast then lock your phone.
  • The Now Playing Info Center should show "voice broadcast" instead of "voice message" and the duration is now equal to the total duration of the voice broadcast.

nowplaying-before

nowplaying-before

@nimau nimau marked this pull request as ready for review January 10, 2023 17:14
@@ -93,6 +94,7 @@ import MediaPlayer
private override init() {
audioPlayers = NSMapTable<NSString, VoiceMessageAudioPlayer>(valueOptions: .weakMemory)
audioRecorders = NSHashTable<VoiceMessageAudioRecorder>(options: .weakMemory)
nowPlayingInfoProviders = NSMapTable<VoiceMessageAudioPlayer, VoiceMessageNowPlayingInfoProvider>(valueOptions: .weakMemory)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this make all voice broadcasting audio players be retained forever?

@giomfo
Copy link
Member

giomfo commented Jan 11, 2023

I tested, this change is working well on ended VB 👍
We just have some trouble in case of buffering, the "now playing info center' considers the playback is stopped
It looks like there is only 2 supported states: playing/stopped

We should check if there is a way to handle this intermediate state (buffering), mainly for live VB. If no solution is available for the moment, we may postpone the management of this potential buffering in the info center view. We should not block this PR for that. The current changes already enhance for some parts the user experience

@nimau nimau force-pushed the nimau/PSF-1734_vb_control_center branch from d25fa41 to b2ae0e7 Compare January 12, 2023 08:35
@nimau
Copy link
Contributor Author

nimau commented Jan 12, 2023

@stefanceriu I made some changes. I tried to be as less invasive as possible to not break anything in the audio players management. Also, the currentlyPlayingAudioPlayer is a bit tricky because we have to consider the player being used by the voice broadcast to be active even if it's stopped (because we're in a buffering state, waiting for the next chunk) to be able to continue to update the NowPlayingInfoCenter.
Can you tell me if it looks ok for you ?

@codecov
Copy link

codecov bot commented Jan 12, 2023

Codecov Report

Base: 11.83% // Head: 11.91% // Increases project coverage by +0.08% 🎉

Coverage data is based on head (648b409) compared to base (3159ba1).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7257      +/-   ##
===========================================
+ Coverage    11.83%   11.91%   +0.08%     
===========================================
  Files         1630     1637       +7     
  Lines       160349   160647     +298     
  Branches     65502    65643     +141     
===========================================
+ Hits         18970    19142     +172     
- Misses      140740   140867     +127     
+ Partials       639      638       -1     
Flag Coverage Δ
uitests 55.23% <ø> (+0.38%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
Riot/Modules/Application/LegacyAppDelegate.m 14.55% <0.00%> (ø)
Riot/Modules/Room/RoomViewController.m 0.00% <0.00%> (ø)
...iceMessages/VoiceMessageMediaServiceProvider.swift 0.00% <0.00%> (ø)
...oordinator/VoiceBroadcastPlaybackCoordinator.swift 0.00% <ø> (ø)
...k/Coordinator/VoiceBroadcastPlaybackProvider.swift 0.00% <0.00%> (ø)
...ck/MatrixSDK/VoiceBroadcastPlaybackViewModel.swift 0.00% <0.00%> (ø)
...oordinator/VoiceBroadcastRecorderCoordinator.swift 0.00% <0.00%> (ø)
...r/Coordinator/VoiceBroadcastRecorderProvider.swift 0.00% <0.00%> (ø)
...vice/MatrixSDK/VoiceBroadcastRecorderService.swift 0.00% <0.00%> (ø)
...odules/Common/DependencyInjection/Injectable.swift 0.00% <0.00%> (-100.00%) ⬇️
... and 25 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -93,6 +94,7 @@ import MediaPlayer
private override init() {
audioPlayers = NSMapTable<NSString, VoiceMessageAudioPlayer>(valueOptions: .weakMemory)
audioRecorders = NSHashTable<VoiceMessageAudioRecorder>(options: .weakMemory)
nowPlayingInfoDelegates = NSMapTable<VoiceMessageAudioPlayer, VoiceMessageNowPlayingInfoDelegate>(valueOptions: .weakMemory)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still worried about this strongly retaining the key/audio player

@stefanceriu
Copy link
Member

As a general rule please don't force push after receiving feedback as it completely breaks where the comments point to

@stefanceriu stefanceriu self-requested a review January 12, 2023 09:46
Copy link
Member

@stefanceriu stefanceriu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small comment inline about how we retain audio players and there's still some opened conversations. Otherwise looks good to me 👍

@nimau
Copy link
Contributor Author

nimau commented Jan 12, 2023

Just a small comment inline about how we retain audio players and there's still some opened conversations. Otherwise looks good to me 👍

Following your comment, I also set the key as weak.

@@ -242,7 +264,7 @@ import MediaPlayer
}
}

private func tearDownRemoteCommandCenter() {
private func tearDownRemoteCommandCenter(for audioPlayer: VoiceMessageAudioPlayer) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The audioPlayer parameter is not used
Can you please remove it?

@sonarcloud
Copy link

sonarcloud bot commented Jan 16, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@nimau
Copy link
Contributor Author

nimau commented Jan 16, 2023

@giomfo as discussed, a live broadcast should not appear in Info Center while playing. Also if the app goes into background while listening a live broadcast, the playback is paused because we cannot get the next chunks.

Copy link
Member

@giomfo giomfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM, I share my comment while I run some additional tests

Copy link
Member

@giomfo giomfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests ok
LGTM

@nimau nimau merged commit a9ff128 into develop Jan 17, 2023
@nimau nimau deleted the nimau/PSF-1734_vb_control_center branch January 17, 2023 08:38
@giomfo giomfo mentioned this pull request Jan 17, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants