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

Implement audio timings #44

Open
Gabixel opened this issue Jan 7, 2024 · 2 comments
Open

Implement audio timings #44

Gabixel opened this issue Jan 7, 2024 · 2 comments

Comments

@Gabixel
Copy link
Owner

Gabixel commented Jan 7, 2024

Editor goals:

  • Have the ability to choose start and stop time
    • (This needs consideration if we want to fully allow files from URLs in the future)
    • stop time has two possible conditions: at and after
      • at meaning it's a specific timestamp
      • after is for durations (e.g. if we want to stop after 10 seconds from the un-/specified start)
  • Show an audio graph? (linked project task)
    • So we need a way to get, calculate, and show the waveform async
    • Also with visuals to see start/end times (opacity, or others)
  • Time will be stored in milliseconds. The Audio object uses decimals for small values (so 500ms is 0.500)
    • The editor will (probably) always show the values like how the Audio object does
@Gabixel
Copy link
Owner Author

Gabixel commented Jan 7, 2024

There's this thread where I just discovered the existence of a "native" time range using the Media Fragments URI specification:

<audio id="my-audio"
       src="file.mp3#t=00:03:26" 
       oncanplaythrough="this.play();">
</audio>

It looks like it supports different styles:

  • timestamps: 00:00:01 / 00:00:01.000
  • seconds (also milliseconds, with the float annotation): 1.123
  • start time only: #t=<start>
  • start/end range: #t=<start>,<end>

This also breaks the current logic for the play/pause button icon (and everything related to audio disposal), even though it looks like the pause event gets called. Maybe it's something related to the playing state, but not sure yet.
I'm not even sure if this is a good alternative to making it from scratch. I will try it since it can probably help with reducing the data needed for long audio files.

Not sure where to find more documentation. I'll link what I can find in the meantime:

@Gabixel
Copy link
Owner Author

Gabixel commented Feb 26, 2024

I'm still leaning toward using media fragments, but they don't seem to end time at the given millisecond value: I noticed that it can get up to 300ms further than expected (average: ~100), and I think there's no limit to that value.
And I'm guessing using other methods like setTimeout() is even worse.

I'm testing on this codepen for the time being.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🧱│Starting / In Progress
Development

No branches or pull requests

1 participant