Skip to content

Conversation

@ezaquarii
Copy link
Collaborator

@ezaquarii ezaquarii commented Jul 8, 2019

This is a new media service based on state machine to address #3061. I tried to salvage the old solution but decided to do a complete re-work. I firmly believe that new architecture will allow us to fix any current and future edge cases easily.

However, the work is not complete yet and there are few issues to consider before we move forward.
Some featutres are cut out, some didn't work anyway, so we need to make Decisions(tm).

Restoring minimized player exists preview

  1. Open media preview
  2. Minimize the screen (media stops)
  3. Restore app from recent apps
    Expected: media preview screen, maybe resume playback?
    Actual: media preview fragment is closed

I discovered that this also happens on current master, so this is an existing issue, not a regression.
This is most likely caused by FileDisplayActivity.onAccountSet(false) which re-sets displayed fragments.

Total time is not displayed when streaming media

I could not confirm if this is regression, as streaming media does not work on prod and master.
It seems that android.media.MediaPlayer returns 0. I can imagine that media file header is not available in streaming mode, but also the media player could do something smart to work around it, so I'd like to have a 2nd opinion.

Here are my results:

mp3 ogg
total 0:00 0:00
progress bar 0:00 stuck at 0:02
rewind nope nope

I'll need some help with testing it in other environments, as I'm not sure if this is expected to work (which require more work, obviously) or not (which require setting some flags to disable those controls).

Media control is a bit wonky

Play-pause is not propagated correctly as it is polling the player. This is something to be addressed with further refactoing.

Audio manager

Audio focus handling is still not implemented, as it is not required at this stage.
Implemented.

Auto-stop on file deletion

Auto-stop on file deletion is currently removed (I left the placeholder to trigger it). Closing preview stops the player and it seems that background playback was not implemented anyway.

Notification is removed for now

Again, no background playback == not needed at this stage. Besides, it didn't provide controls, so more work is needed if we want to bring that into usable state.
Old notification behavior is restored.

Last but not least is the StateMachine framework

No longer an issue - I'm a maintainer and stateless4j is in good shape again.

@tobiasKaminsky @AndyScherzinger @DPTJKKVH Please give it a go and let me know how we'd like to proceed with that.

Fixes #4515

@DPTJKKVH
Copy link

DPTJKKVH commented Jul 8, 2019

@ezaquarii @nextcloud-android-bot Amazing! I will give it a thorough test tomorrow after work. (Tuesday)

@redtux
Copy link

redtux commented Jul 9, 2019

Unortunately, it is not working. I have just installed the above build and successfully logged in, but when clicking play on an mp3 file the client immediately crashes. (Been trying several times, so it's reproducible.) 😕

@ezaquarii
Copy link
Collaborator Author

ezaquarii commented Jul 9, 2019

Unortunately, it is not working. I have just installed the above build and successfully logged in, but when clicking play on an mp3 file the client immediately crashes. (Been trying several times, so it's reproducible.) confused

Thanks for testing.

I'll try to ship another build with ACRA crash reporter later this evening, so people actually can get a chance to submit helpful bug reports.

In the meantime, if you can get any logs from logcat (I know few people have development tools installed, so no worries if you can't), it would help to figure it out. Ne need, the app provides the stack trace now.

@redtux
Copy link

redtux commented Jul 9, 2019

I have logcat installed, but my phone is not rooted and the adb command is not working. I'll try your next build and upload the resulting output here. Thank you in advance! 👍

@ezaquarii ezaquarii force-pushed the ezaquarii/new-media-player-service branch from 4157b1b to fbec2d5 Compare July 9, 2019 20:48
@DPTJKKVH
Copy link

DPTJKKVH commented Jul 9, 2019

I will wait for the new build as well. Thanks from me, too! 👍

@ezaquarii ezaquarii force-pushed the ezaquarii/new-media-player-service branch from fbec2d5 to c716468 Compare July 9, 2019 20:51
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
@nextcloud nextcloud deleted a comment Jul 9, 2019
Copy link
Member

@tobiasKaminsky tobiasKaminsky left a comment

Choose a reason for hiding this comment

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

Some small questions / change ideas

@ezaquarii
Copy link
Collaborator Author

ezaquarii commented Sep 27, 2019 via email

@tobiasKaminsky
Copy link
Member

Bug(?):

  • start an audio
  • suspend app
  • restart app
  • click on pause
  • click on back
  • still see "is playing" notification

Old behaviour was that when pausing (as we do not have a stop) and leaving player the notification is gone away.

@tobiasKaminsky
Copy link
Member

Except this, it looks very very good and is working fine 🎉 🎉 🎉 🎉
I guess this is a huge enhancement.
Thanks again for your wonderful work!

@ezaquarii
Copy link
Collaborator Author

ezaquarii commented Sep 27, 2019

Bug(?):

Weeeeell, yes and no, aka it's complicated.

Previous implementation simply turned off service foreground mode, but did not care about clearing the player state nor even releasing the binders.

This had a side effect of clearing the icon, but the player was left in paused state. It was usually also bound to FileListActivity (and derivatives) as well, preventing the service from being destroyed by the OS most of the time.

Relying on a background service to retain it's state guarantees to have funky edge issues caused by Android resources reclamation.

Current implementation preserves the backgrounding behaviour of old player, but does not disable foreground mode, which manifests itself with the icon being still on screen (because the player is technically still up and running, just paused). Otherwise it works as the old one MINUS possible breakages on service kill.

I added a STOP button to the notification, so you can stop the player if needed.

I was hoping that we simply add proper media player controls to this notification, like every other media player does, allowing the user to go back, pause, resume and stop from there.

If the old behavior is important to retain, we could:

  1. bind the service to MainApp to protect it against Grim Reaper in paused-and-not-foreground state
  2. toggle foreground mode when entering/exiting paused state

This won't play nice if we want to have media controls in notification, as pausing it would close the media controls (and then you can resume it again of course).

We have some complaints about the current pause/stop experience, and I think this "magical" pausing is not a good UX at all.

Let me know what we want to do here.

Fixes #3061
Fixes #4412

Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
@ezaquarii ezaquarii force-pushed the ezaquarii/new-media-player-service branch from c29fcd1 to 2dab887 Compare September 27, 2019 19:14
@nextcloud-android-bot
Copy link
Collaborator

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/11019.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@nextcloud nextcloud deleted a comment Sep 27, 2019
… [skip ci]

Signed-off-by: nextcloud-android-bot <android@nextcloud.com>
@nextcloud-android-bot
Copy link
Collaborator

Codacy

277

Lint

TypemasterPR
Warnings5959
Errors00

SpotBugs (new)

Warning TypeNumber
Bad practice Warnings27
Correctness Warnings69
Internationalization Warnings12
Malicious code vulnerability Warnings4
Multithreaded correctness Warnings9
Performance Warnings120
Security Warnings47
Dodgy code Warnings139
Total427

SpotBugs (master)

Warning TypeNumber
Bad practice Warnings27
Correctness Warnings69
Internationalization Warnings12
Malicious code vulnerability Warnings4
Multithreaded correctness Warnings9
Performance Warnings120
Security Warnings47
Dodgy code Warnings141
Total429

@nextcloud-android-bot
Copy link
Collaborator

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/11020.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@nextcloud nextcloud deleted a comment Sep 27, 2019
@nextcloud-android-bot
Copy link
Collaborator

Codacy

277

Lint

TypemasterPR
Warnings5959
Errors00

SpotBugs (new)

Warning TypeNumber
Bad practice Warnings27
Correctness Warnings69
Internationalization Warnings12
Malicious code vulnerability Warnings4
Multithreaded correctness Warnings9
Performance Warnings120
Security Warnings47
Dodgy code Warnings139
Total427

SpotBugs (master)

Warning TypeNumber
Bad practice Warnings27
Correctness Warnings69
Internationalization Warnings12
Malicious code vulnerability Warnings4
Multithreaded correctness Warnings9
Performance Warnings120
Security Warnings47
Dodgy code Warnings141
Total429

@tobiasKaminsky
Copy link
Member

I added a STOP button to the notification, so you can stop the player if needed.

Nice, I think this is enough.

I was hoping that we simply add proper media player controls to this notification, like every other media player does, allowing the user to go back, pause, resume and stop from there.

This would indeed be very cool, but should be done in another PR 👍

@tobiasKaminsky tobiasKaminsky merged commit 0f97564 into master Oct 1, 2019
@delete-merged-branch delete-merged-branch bot deleted the ezaquarii/new-media-player-service branch October 1, 2019 05:45
@tobiasKaminsky
Copy link
Member

Thanks again for this great PR 🎉 🎉 🎉

@AndyScherzinger AndyScherzinger added this to the Nextcloud App 3.9.0 milestone Oct 1, 2019
tobiasKaminsky added a commit that referenced this pull request Oct 2, 2019
ea696c5 Merge pull request #4425 from nextcloud/autoUploadSubfolder
37c6600 Upload files into subfolder
a1c28f9 Merge pull request #4470 from stephanritscher/master
9c1fedb add test cases
6184fcd add test cases
0f97564 Merge pull request #4208 from nextcloud/ezaquarii/new-media-player-service
d83792e [tx-robot] updated from transifex
9a2fc28 [tx-robot] updated from transifex
f10843e daily dev 20190928
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.

Music Player gets unaccessible although playback is on

7 participants