dimitris-c / AudioStreaming

An AudioPlayer/Streaming library for iOS written in Swift using AVAudioEngine.
MIT License
266 stars 56 forks source link

Allow playing back from a specific TimeInterval #21

Closed bogo closed 3 years ago

bogo commented 3 years ago

First of all - thank you so much for this library! It's really helpful in the project I'm working at right now.

I noticed that the API for AudioPlayer has separate play(url:) and seek(to:) methods. I would love to be able to merge these two and ask the AudioPlayer to start playing back the item at a specific location. (i.e. play(url:at:))

When I tried to simulate this behavior by calling play and seek in a sequential order, the seek command seemed to be ignored, unless I delay it slightly via DispatchQueue. I assume it's due to the time it takes for the item to enter audioPlayingEntry.

How would you go about implementing playback at a specific time interval? Happy to look into this and try to make a PR out of it, but would appreciate some guidance! :)

dimitris-c commented 3 years ago

Hey, I'm glad you find this library useful.

I haven't got a chance to look at this in depth. But I would add a new play method that takes both the url and a seek offset. Then I would make the required changes to the RemoteAudioEntry class to support this functionality.

It shouldn't be that hard to be honest.

Have a look at it if you have the time and feel free to create a PR.