Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.

feat: stream time statistics#75

Merged
amishshah merged 3 commits into
mainfrom
feat/audio-resource-stream-time
Mar 13, 2021
Merged

feat: stream time statistics#75
amishshah merged 3 commits into
mainfrom
feat/audio-resource-stream-time

Conversation

@amishshah
Copy link
Copy Markdown
Member

@amishshah amishshah commented Mar 13, 2021

Please describe the changes this PR makes and why it should be merged:

Resolves #71

Adds playbackDuration to both AudioPlayer and AudioResource:

  • AudioResource.playbackDuration is incremented by 20ms every time an Opus packet is read from its underlying Opus stream. This value can be thought of as the progress through an audio track. It starts off at 0.

  • AudioPlayer.state.playbackDuration is available in the Playing, Paused, and AutoPaused states. It is incremented by 20ms every time an Opus packet (whether from the audio resource, or a filler silence packet) is prepared for dispatch by the subscribers. This value can be thought of as the "real" playback time, including any transmission gaps. It resets back to 0 when playing a new resource.

You can therefore derive the length of time that filler silence has been played as the difference between these two quantities.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • This PR changes the library's interface (methods or parameters added)

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 13, 2021

Codecov Report

Merging #75 (86e7568) into main (c4fa5a6) will increase coverage by 0.83%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #75      +/-   ##
==========================================
+ Coverage   28.98%   29.81%   +0.83%     
==========================================
  Files          15       15              
  Lines         590      597       +7     
  Branches      131      132       +1     
==========================================
+ Hits          171      178       +7     
  Misses        417      417              
  Partials        2        2              
Impacted Files Coverage Δ
src/audio/AudioPlayer.ts 77.51% <100.00%> (+0.35%) ⬆️
src/audio/AudioResource.ts 43.47% <100.00%> (+15.70%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c4fa5a6...86e7568. Read the comment docs.

@amishshah amishshah requested a review from vladfrangu March 13, 2021 12:04
@amishshah amishshah merged commit ced3102 into main Mar 13, 2021
@amishshah amishshah deleted the feat/audio-resource-stream-time branch March 13, 2021 12:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stream time information

2 participants