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

feat: Add function to get elapsed time of playing audio on VoiceClient #2587

Merged

Conversation

felix920506
Copy link
Contributor

@felix920506 felix920506 commented Sep 23, 2024

Summary

Adds a function to get the elapsed seconds of currently playing audio file

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@felix920506 felix920506 requested a review from a team as a code owner September 23, 2024 02:35
@pullapprove4 pullapprove4 bot requested a review from Dorukyum September 23, 2024 02:35
@felix920506 felix920506 changed the title feat: Add function to get elapsed time of playing audio feat: Add function to get elapsed time of playing audio on VoiceClient Sep 23, 2024
@JustaSqu1d
Copy link
Member

Seconds seem really inflexible, what if we returned a datetime.timedelta object instead?

@felix920506
Copy link
Contributor Author

Sounds reasonable

@felix920506
Copy link
Contributor Author

Can I have a review on this?

discord/player.py Outdated Show resolved Hide resolved
@felix920506 felix920506 requested a review from Dorukyum October 5, 2024 00:46
@felix920506
Copy link
Contributor Author

Changed to use loops + an offset to keep track of when loops gets reset

discord/voice_client.py Outdated Show resolved Hide resolved
Copy link
Member

@Dorukyum Dorukyum left a comment

Choose a reason for hiding this comment

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

I find client.elapsed() to be clearer and simpler, what do you think?

CHANGELOG.md Outdated Show resolved Hide resolved
discord/voice_client.py Outdated Show resolved Hide resolved
discord/voice_client.py Outdated Show resolved Hide resolved
@felix920506
Copy link
Contributor Author

I don't have any preference between client.elapsed() or client.played_time()
If you think client.elapsed() is better then let's use that

Co-authored-by: Dorukyum <[email protected]>
Signed-off-by: felix920506 <[email protected]>
@Lulalaby Lulalaby merged commit 9a83a2a into Pycord-Development:master Oct 11, 2024
25 checks passed
baribarton pushed a commit to baribarton/pycord-no-potential-reconnect that referenced this pull request Oct 24, 2024
Pycord-Development#2587)

* add played_seconds function

* Update CHANGELOG.md

* style(pre-commit): auto fixes from pre-commit.com hooks

* use datetime.timedelta instead of int

* add comment

* style(pre-commit): auto fixes from pre-commit.com hooks

* rename function to reflect change

* style(pre-commit): auto fixes from pre-commit.com hooks

* don't use different counter

* Update discord/voice_client.py

Signed-off-by: Dorukyum <[email protected]>

* Apply suggestions from code review

Co-authored-by: Dorukyum <[email protected]>
Signed-off-by: felix920506 <[email protected]>

---------

Signed-off-by: felix920506 <[email protected]>
Signed-off-by: Dorukyum <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dorukyum <[email protected]>
OmLanke pushed a commit to OmLanke/pycord that referenced this pull request Dec 16, 2024
Pycord-Development#2587)

* add played_seconds function

* Update CHANGELOG.md

* style(pre-commit): auto fixes from pre-commit.com hooks

* use datetime.timedelta instead of int

* add comment

* style(pre-commit): auto fixes from pre-commit.com hooks

* rename function to reflect change

* style(pre-commit): auto fixes from pre-commit.com hooks

* don't use different counter

* Update discord/voice_client.py

Signed-off-by: Dorukyum <[email protected]>

* Apply suggestions from code review

Co-authored-by: Dorukyum <[email protected]>
Signed-off-by: felix920506 <[email protected]>

---------

Signed-off-by: felix920506 <[email protected]>
Signed-off-by: Dorukyum <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dorukyum <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants