TortugaPower / BookPlayer

Player for your DRM-free audiobooks
GNU General Public License v3.0
1.53k stars 186 forks source link

Dynamic Siri Shortcuts for the books in the library to jump to and (optionally) continue playback immediately #409

Open boettges opened 4 years ago

boettges commented 4 years ago

Hey everyone, a little feature suggestion:

There are books that are not meant for continuous reading/listening. Typical examples are those "365 questions ..."-style books, which consist of very short chapters that usually are read one by one on a daily basis.

It would be great to have the following Siri Shortcut suggestions from BookPlayer in the Shortcuts app to: 1) Jump to book X (without automatic playback) 2) Continue playback of book X (with the optional toggle "Show When Run" so that playback could be started entirely in the background)

Examples for apps that only use those donated Siri Shortcuts are: Good Notes 5, iConnectHue and WhatsApp. There are also apps that have pre-defined basic actions plus some dynamic suggestions, such as: Overcast, Bear, Habitify and Just Timers

This would allow to integrate BookPlayer seamlessly into routine Shortcuts and the new Shortcut automations (iOS 13), such as: "When my alarm is stopped, switch my lights on, show the calendar items of the day, after that show the weather forecast and then open book X in BookPlayer ."

Thanks a lot in advance 👌

GianniCarlo commented 4 years ago

3.8.0 will introduce the Intents extension, which opens up these possibilities. I've added a new resume-last-played shortcut, which can be ran in the background, and also a sleep timer shortcut, which can't be run in the background sadly (because of some limitations explained here https://github.com/TortugaPower/BookPlayer/issues/338#issuecomment-614282470).

But the basis for new shortcuts is set in the project, for anyone interested, in the AppDelegate this is where it all happens:

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
     ActionParserService.process(userActivity)

     return true
}

ActionParserService underneath handles all the Actions parsed by the class CommandParser which parses/extract actions from: intents/shortcuts, url scheme and watch app extension communications. So in CommandParser would go the specification of new actions