readium / swift-toolkit

A toolkit for ebooks, audiobooks and comics written in Swift
https://readium.org/mobile/
BSD 3-Clause "New" or "Revised" License
256 stars 100 forks source link

Extracting `t` fragment from `Locator` #372

Closed domkm closed 7 months ago

domkm commented 9 months ago

What do you think of providing a method of extracting time(s) from a Locator

There is a private extension on Locator which kind of does this, but looks like it only matches start time (my understanding is that end time can be specified).

https://github.com/readium/swift-toolkit/blob/a62962bbb862a5852ce8f79c5369213f38c79e8e/Sources/Navigator/Audiobook/AudioNavigator.swift#L389-L409

Would you be open to a Locator.time property/function (() -> (Double?, Double?)?). I'd be open to providing a PR for this if you want.

mickael-menu commented 8 months ago

For sure, that would be helpful! Thank you.

This extension should be on Locator.Locations though, you can take inspiration from this HTML extension: https://github.com/readium/swift-toolkit/blob/a62962bbb862a5852ce8f79c5369213f38c79e8e/Sources/Shared/Publication/Extensions/HTML/Locator+HTML.swift

As for the result, I'd prefer a struct or at least tuple with named values.