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

Improve Media Player #13467

Merged
merged 18 commits into from
Sep 12, 2024
Merged

Improve Media Player #13467

merged 18 commits into from
Sep 12, 2024

Conversation

parneet-guraya
Copy link
Contributor

@parneet-guraya parneet-guraya commented Aug 26, 2024

Fixes:
#925
#5037
#11810
#7462 [ PlayerService that used legacy media library no longer used so it makes it obsolete I guess?]

Changes Introduced:

  • Audio files now can be streamed over network.
  • Audio playback in background with nice media style notification.
  • Both Audio & Video players can handle commands from Bluetooth and Wired earphones.
  • Both Audio & Video players implements MediaSession that means any media controller can connect to it and control it. Example Google Assistant, smart watch etc
  • Remove dependency on service that used legacy media for audio playback. yet to remove the files in separate PR.
  • Support managing audio focus i.e Audio ducking, Audio focus loss.
Record_2024-09-04-04-53-22.mp4

Notification Styles

Oneplus Android 14

Screenshot_2024-09-04-04-53-55-21

Stock Android 12

Screenshot from 2024-09-04 05-00-34

Stock Android 13 & 14

Screenshot from 2024-09-04 05-02-39

Copy link

github-actions bot commented Sep 9, 2024

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Copy link
Collaborator

@alperozturk96 alperozturk96 left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! I've created a Git patch to eliminate the use of the "!!" operator.

force_unwrap1.patch

Could you apply this patch?

Additionally, the use of runBlocking blocks the current thread until it completes. BackgroundPlayerService runs on the main thread. I tested, general flow looks okay. It might be acceptable in this case, but for initNextcloudExoPlayer(), would it be possible to notify the service after this function finishes?

@parneet-guraya
Copy link
Contributor Author

parneet-guraya commented Sep 9, 2024

Thank you for your contribution! I've created a Git patch to eliminate the use of the "!!" operator.

force_unwrap1.patch

Could you apply this patch?

Sure, @alperozturk96

Additionally, the use of runBlocking blocks the current thread until it completes. BackgroundPlayerService runs on the main thread. I tested, general flow looks okay. It might be acceptable in this case, but for initNextcloudExoPlayer(), would it be possible to notify the service after this function finishes?

Ah, I was aware of this forgot to add the comment. I know it would block the main thread it's just that the Nextcloud client needs to be created on background thread. but in that time service already starts and player doesn't get initialized. It doesn't do that much of a task while creating a client so I add a run blocking so to wait for the client.

Also, we're not the one starting the service, it is started when session token is created. So no way we can tell it to start after the client init on background.

since controlling when service starts not in our control. Can we have some other option to inject Exoplayer without having to create client instance? tell me if you have any ideas I will see.

thanks 👍

@alperozturk96
Copy link
Collaborator

@parneet-guraya Could you please address the Codacy Static Code Analysis issues and apply a git patch to eliminate the use of the !! operator so we can proceed with the merge? Thanks for your contribution! 💯

Signed-off-by: parneet-guraya <[email protected]>
Signed-off-by: parneet-guraya <[email protected]>
Signed-off-by: parneet-guraya <[email protected]>
Signed-off-by: parneet-guraya <[email protected]>
Signed-off-by: parneet-guraya <[email protected]>
Signed-off-by: parneet-guraya <[email protected]>
Signed-off-by: parneet-guraya <[email protected]>
Signed-off-by: parneet-guraya <[email protected]>
Signed-off-by: parneet-guraya <[email protected]>
Signed-off-by: parneet-guraya <[email protected]>
@parneet-guraya
Copy link
Contributor Author

@alperozturk96 hi, applied the patch, also what would you say about use of runBlocking although works fine as intended, maybe you missed but I explained it in my comment above. So, maybe we can move forward with this one and later remove use of this?

Copy link

Codacy

Lint

TypemasterPR
Warnings5959
Errors33

SpotBugs

CategoryBaseNew
Bad practice6363
Correctness6464
Dodgy code299299
Experimental11
Internationalization77
Multithreaded correctness66
Performance5353
Security1818
Total511511

Copy link

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/13467.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.

@alperozturk96
Copy link
Collaborator

@alperozturk96 hi, applied the patch, also what would you say about use of runBlocking although works fine as intended, maybe you missed but I explained it in my comment above. So, maybe we can move forward with this one and later remove use of this?

I agree, no need to block this improvement, thank you 👍

@alperozturk96 alperozturk96 merged commit 233d8a9 into master Sep 12, 2024
21 checks passed
@alperozturk96 alperozturk96 deleted the improve-media branch September 12, 2024 09:20
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.

2 participants