goxr3plus / java-stream-player

🌌Java Advanced Audio Controller Library (WAV, AU, AIFF, MP3, OGG VORBIS, FLAC, MONKEY's AUDIO and SPEEX audio formats )
GNU General Public License v3.0
147 stars 33 forks source link

Add getDurationInMilliseconds() to StreamPlayer API #61

Closed AObuchow closed 4 years ago

AObuchow commented 4 years ago

My application is meant to play audio files which are sometimes shorter than 1 second (eg. Drum sounds for music production). For this case, it'd be useful to have a getDurationInMilliseconds() function in the StreamPlayer class.

I saw that the getDurationInSeconds() implementation for FileDataSource calls TimeTool.durationInSeconds() which is implemented with TimeTool.durationInMilliseconds(name, type). This gives me hope that this wouldn't be too hard to add to the StreamPlayer API.

I'd like to submit a PR for this, however I wanted to bring up the topic before I get to work on it.

Any thoughts?

goxr3plus commented 4 years ago

I completely agree with your idea :) Go ahead

goxr3plus commented 4 years ago

I was going to do it but i have many projects to support, the repo is yours to add any functionality you want :)

HelgeStenstrom commented 4 years ago

It looks very reasonable. Make sure it returns a long, not an int.

It might also be useful to have methods getDuration, that returns a java.lang.Duration, instead of an int or a long. It's more flexible, but probably has some performance overhead.

AObuchow commented 4 years ago

Thanks for the go-ahead, @goxr3plus :)!

AObuchow commented 4 years ago

It looks very reasonable. Make sure it returns a long, not an int.

Good call!

It might also be useful to have methods getDuration, that returns a java.lang.Duration, instead of an int or a long. It's more flexible, but probably has some performance overhead.

I like this idea, I'll definetly look into it :+1:

AObuchow commented 4 years ago

@goxr3plus now that my fix is upstream, would you be able to release version 10.0.1 of java-stream-player, when you have a moment?

I realize it might get tedious for you to have to do the releases, so maybe I can help automate the deploy process? If you're able to give me instructions on how you usually deploy, I could hopefully create a GitHub Actions Workflow which automates this when the Master branch is updated.

Alternatively, I could deploy my fork of java-stream-player to GitHub Packages (or some other hosting service) under a different Maven groupId. Then after a while, you can deploy yourself after enough new features are added :)