Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
Is there a Shortcuts action which plays the current Audiobook track and stops when it's done, and get the next track ready?

I'm listening to an Audiobook which consists of multiple MP3 files (one MP3 equals one chapter), and I'd like to listen to just one chapter each time I run the Shortcut, and the next time I run the Shortcut it'll either continue playing the current track till the end (and stop), or (in case the previous track has already been played till the end) it'll start playing the next track and stop.
I've already succeeded in making a Shortcuts which plays a specific Audiobook, but it just keeps playing the next track from the same Audiobook. It looks like this:

- SET VOLUME TO [35%]
- OPEN [Books app]
- PLAY [Specific] [Audiobook] [name_of_Audiobook]
 
Last edited:

Slartibart

macrumors 68030
Aug 19, 2020
2,892
2,597
Are these individual mp3 files or wrapped in an audiobook? Which version of iOS? I don’t listen to audiobooks, but you might use the »Find Music«-command specifying filter conditions e.g. the title of your audiobook (or the Artist, or whatever relevant meta data is available), media kind = audiobook, as well as Play Count = 0 to get to the next unplayed chapter of your audiobook and then use the »Play Music«-command.
The »Find Music«-command offers to filter for Track Number, maybe this can be applied to select a specific chapter (?)

Just as mockups :

IMG_2563.jpeg


or

IMG_2564.jpeg


try and please report 😎
 

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
Thanks for your suggestions. I've already started working on it, on my iPad, but can't quite get it to work and have some thoughts and questions about that, but first some answers:

Are these individual mp3 files or wrapped in an audiobook? Which version of iOS?

This is in iPadOS 16.5.1.
They are all individual MP3 files.
Actually they originate from an online Podcast which I subscribed to and downloaded (using iTunes on my Mac), resulting in lots of MP3 files.
I then (also within iTunes on the Mac) changed the media kind to "Audiobook", added metadata such as title, track numbers, genre etc. to organize them properly, and once transferred over to my iPad (or iPhone) the audiobook is accessed there using the Books iOS app.

What I don't understand about your suggestions is that they appear to use the Music app, but is this used merely for controlling the MP3 files to allow for stopping once the track has been played etc, while I can still use Books to open and see the file in question?
Or would it be better suited to first change the media kind to "Music" in iTunes before once again transferring the files over to the iPad? I fear it might not work in the same way as with an audiobook when being played with the Music app, loosing out on some functionality, but I'm open for ideas, comments and suggestions of course.
 

Slartibart

macrumors 68030
Aug 19, 2020
2,892
2,597
if the iTunes media meta data is set correctly you might be probably able to play your audiobook stored in Books through the Music app… maybe you just give it a try. 😃

The iTunes media denominator is the important bit here - if one tries to play e.g. a MP3 file downloaded into Apple’s Files through Music you get some error:

IMG_2566.jpeg


My guess is that you have no such problems because you sync through iTunes from your Mac; the meta data you assign might impact here; YMMV 😀
 

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
I think I understand the general idea,
but frustratingly the biggest challenge now is to find the correct Shortcuts Actions to match the ones in your screenshot!
Which Action have you used in the screenshot above where it says "Receive [Media and 2 more] input from [Share Sheet]" ? I searched for "Receive" in the Shortcuts app, but there was no Action by that name.

It'll be interesting to see if it'll work with the Books app. When I sync through iTunes on my Mac I do it manually by dragging/dropping the MP3 files on to the "On my device" section (which then highlights the entire section when I have the mouse pointer over it). When I drop the MP3 files on to it and the sync is done I can click on the device's "Audiobook" section and see the MP3 files there, so I've always assumed those files are placed in the iPad's Books app folder, making them available to only that app, but from what you're saying here I understand the files may actually be accessible from other iOS apps as well?
 

Slartibart

macrumors 68030
Aug 19, 2020
2,892
2,597
Which Action have you used in the screenshot above where it says "Receive [Media and 2 more] input from [Share Sheet]" ? I searched for "Receive" in the Shortcuts app, but there was no Action by that name.

Add the Find Music-command to your Shortcut, tap All Music and change it to Shortcut Input.

IMG_2578.jpeg


It will change to the Receive… From there continue and e.g. add and adjust additional filters, etc..
 

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
Thanks again for your help.
I realize this is a bit over my head, as I've so far only touched simple Shortcuts actions with basic settings, so maybe I need to spend some time learning Shortcuts properly first.
I so far haven't gotten it to work, and at this stage I don't know if it's because it simply can't be done this way or if I've misunderstood it all.

However, I might have found something useful (How to listen to audiobook in Apple Books on iPhone and iPad) as there's apparently an option which comes up when an audiobook is playing, which does exactly what I want.
Here's a screenshot from my iPad playing an audiobook track:

ios_audiobook_sleeptimer.jpg


What I do is tap the "Sleep timer" icon at the bottom left side where there's an option named "When current chapter ends". This plays the current track, stops and brings the next track up.
Now, I looked up actions for both "Timer" and "Sleep" but apparently Apple haven't made it this easy.

Do you know if there's another way of accessing this feature for use in Shortcuts?
 

Slartibart

macrumors 68030
Aug 19, 2020
2,892
2,597
Set Timer will work straight forward - the only problem is that a timer will play the sound preselected in the clock app at the end, so that’s probably not what you want. 🙃

As far as I understand you want a sleep timer and a player of the current audiotrack (or even better IMHO, create a playlist of current and not played tracks) - there are free shortcuts on e.g. Routinehub or Shortcutsgallery which you can study, download and/or use. You could then let your iPad do what you want by e.g. running 2 shortcuts at the same time - btw. the reddit shortcut group linked is quite helpful.

nota bene: using a silent sound for the timer alert is probably a solution 🤣… you still have to dismiss the timer notification. Setting a custom focus mode is probably the better option.
 

arw

macrumors 65816
Aug 31, 2010
1,092
857
I know it's not the native Books app, but Prologue offers the Shortcuts option you seek.
Prologue is a free iOS audiobook player that relies on a Plex server instance to get its media. An in-app-purchase unlocks downloading the audiobooks locally for offline playback.
 

Attachments

  • IMG_1540.jpeg
    IMG_1540.jpeg
    109.6 KB · Views: 42
Last edited:

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
Set Timer will work straight forward - the only problem is that a timer will play the sound preselected in the clock app at the end, so that’s probably not what you want. 🙃

Huh? Nothing came up in the Shortcuts iOS app when searching for "Set Timer". The only timer related action is "Start Timer" with just the ability to set the amount of minutes, seconds or hours.
Also, I tried playing an audiobook track with the sleep timer set as in my screenshot in posting #7, but there was no alarm clock sound at the end. So if there's a way to include the same sort of timer setup as in that screenshot in some way it would solve everything as far as I can see.


As far as I understand you want a sleep timer and a player of the current audiotrack (or even better IMHO, create a playlist of current and not played tracks) - there are free shortcuts on e.g. Routinehub or Shortcutsgallery which you can study, download and/or use. You could then let your iPad do what you want by e.g. running 2 shortcuts at the same time - btw. the reddit shortcut group linked is quite helpful.

Thanks. I'll look into those links.


nota bene: using a silent sound for the timer alert is probably a solution 🤣… you still have to dismiss the timer notification. Setting a custom focus mode is probably the better option.
Good suggestion about using a silent audio file as a non-audible alert.
But again I'm a little confused because I neither get an alert sound at the end of the track, nor do I get a notification to dismiss. The track just stops and the next track gets ready (while still in pause mode).


I know it's not the native Books app, but Prologue offers the Shortcuts option you seek.
Prologue is free iOS audiobook player that relies on a Plex server instance to get its media. An in-app-purchase unlocks downloading the audiobooks locally for offline playback.

Interesting.
Do the additional Shortcuts options show up after having installed the Prologue app? I always thought they were only part of iOS.

I've spent quite a lot of effort in organizing ebooks, PDFs and audiobooks within the Books app so I hope this doesn't mean I have to reorganize everything again if I decide to use Prologue instead of Books?
 

arw

macrumors 65816
Aug 31, 2010
1,092
857
Do the additional Shortcuts options show up after having installed the Prologue app? I always thought they were only part of iOS.
Yes. Additionally installed apps can add their own interface/features to Shortcuts.app.
I've spent quite a lot of effort in organizing ebooks, PDFs and audiobooks within the Books app so I hope this doesn't mean I have to reorganize everything again if I decide to use Prologue instead of Books?
I can't give a definite answer.
In regard to audiobooks: If you tagged them properly by using tools like Subler, Mp3tag or Metadatics then all the information is stored in the files themselves.
iTunes on the other hand does not write all metadata changes back into the files (like mediakind: audiobook).
But Artist, Album, Title, Tracknumber, etc. should be saved back into the files. I suspect Books behaves similar but I've never used it to edit metadata.

(I use Mp3tag to automatically grab Author, Narrator, Genre and Description/Plot and write them properly into the files.)

EDIT:
Or would it be better suited to first change the media kind to "Music" in iTunes before once again transferring the files over to the iPad?
This would probably offer a lot more options like getting the remaining time of the current track to set a timer.
Then add an automation to stop playback when a timer ends. (provided you don't run into the same problems on different devices like @Slartibart )
You could also 'cache' the current track's information (into a local text file) so Music.app can resume the correct album/track later.
 
Last edited:
  • Like
Reactions: Slartibart

Slartibart

macrumors 68030
Aug 19, 2020
2,892
2,597
Huh? Nothing came up in the Shortcuts iOS app when searching for "Set Timer". The only timer related action is "Start Timer" with just the ability to set the amount of minutes, seconds or hours.
My bad, of course it is Start Timer. As written, easy to use but it comes with the ”effects” 🤓 mentioned… as long as you script it. If you create a timer in the Clock app with When Timer Ends>Stop Playing selected and then start manually e.g. playing some music, followed by starting the timer - it will end the music after the defined time and not play an alert sound. On the devices I tried, it behaves differently when doing the same from within Shortcuts. 🤷‍♀️



AFAIK Apple’s Books - or iOS/iPadOS <= 17b3 - do not present access to the “sleep” timer Apple’s Books (or the system) offers.
 

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
AFAIK Apple’s Books - or iOS/iPadOS <= 17b3 - do not present access to the “sleep” timer Apple’s Books (or the system) offers.

Aha! So until iOS/iPadOS 17 is released I don't actually get to use this action in my Shortcut 😕
I suppose it's not a good idea for me to upgrade from my current 16.5.1. to the latest beta release, being an end-user and not a developer?


My bad, of course it is Start Timer. As written, easy to use but it comes with the ”effects” 🤓 mentioned… as long as you script it. If you create a timer in the Clock app with When Timer Ends>Stop Playing selected and then start manually e.g. playing some music, followed by starting the timer - it will end the music after the defined time and not play an alert sound. On the devices I tried, it behaves differently when doing the same from within Shortcuts. 🤷‍♀️

So you can create Shortcuts with scripts in the same way as Applescripts on a Mac! That probably gives much more possibilities than the simple way I've created Shortcuts (just adding Actions after each other).

I'd like to give this a try (and use a silent audio file or even a custom made "the audiobook chapter is now finished" type of sound at the end) if this is accessable through the use of scripting.
I tried to find something by searching for "script", but although not obvious I'm wondering if one of the script functions can "dig into" the otherwise not available options of the "Start Timer" action?
If I could only enable the sleep timer and select "when current chapter ends"...
How would I go about to add this as a script? Maybe there's an option for selecting what's actually available on the audiobook playback screen (i.e. "tap the "sleep timer icon", "select: when current chapter ends") or something along those lines?
 

Slartibart

macrumors 68030
Aug 19, 2020
2,892
2,597
Aha! So until iOS/iPadOS 17 is released I don't actually get to use this action in my Shortcut 😕
I suppose it's not a good idea for me to upgrade from my current 16.5.1. to the latest beta release, being an end-user and not a developer?

No. iPadOS 17 does not offer access to Books’s sleep timer. As I wrote: “or iOS/iPadOS <= 17b3 - do not present access” , that’s a “less than” followed by an “equal” before “17b3” - my crude intent to short cut writing “less then and equal”. 🥹

Apple provides Shortcuts on iOS/iPadOS and macOS; and Shortcuts, Automator, and Applescript on macOS. While Shortcuts is available on both (or better the three) platforms, there are some differences. macOS is by far the more mature and capable (!!!) programming platform.

If you want help with using Apple Script to script Apple Books on macOS, I recommend to google first. If this doesn’t immediately gives you a starting solution, open for example here on MR a new thread in the macOS forum, explain what you want, show what you programmed so far and document the problem you run into.




But of course this does not help you with controlling the playback of audiobooks on your iDevices.




From what I know and learned through your thread here, at the moment the solutions for what you want to do on iOS/iPadOS are:
  • use and control a (as indicated free) 3rd-party app via Shortcuts.
  • create a shortcut which basically runs 2 other shortcuts: 1.) a sleep timer, 2.) an audiobook "player" - you find various sleep timer on the Shortcut-websites referenced previously or elswhere; there are 2 solutions mentioned in this thread to use Shortcuts to play audiobooks, via Apple Books or a “play” script similar to the above.
  • Simply use the way Apple Books provides - no scripting needed. 😁

nota bene:

this a try (and use a silent audio file or even a custom made "the audiobook chapter is now finished" type of sound at the end) if this is accessable through the use of scripting.

If you add a timer to a script before any play-command like in the previous screenshots (if you just want to play the current audiobook you not even have to go though the Find Music stuff to find e.g. unplayed or whatever else specified audiobooks etc., you can just use the Play Current-command) you have exactly that. In Shortcuts. On iOS/iPadOS. With an IMHO 🤣 annoying (YMMV 😀) selectable sound played at the end of the defined play time.
 

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
Thanks to both of you for lots of great advice!
Lots of ideas which I need to re-read a few times to fully understand and try out. I want to try adding the timer to a script as suggested above, but as I don't understand where to even look for or enter those parameters I'll see what I can learn about iOS scripting first.
 

Slartibart

macrumors 68030
Aug 19, 2020
2,892
2,597
The following let’s you select a mp3 or other supported audio file located within Apple’s Files app. Then it opens the Timer tab in the Clock app, sets and starts a 10 second timer and plays the selected audio file. You have to change Play Sound to Play Current to play the current audiobook - a basic version of what you want AFAIU.

IMG_2608.jpeg
 

macstatic

macrumors 68010
Original poster
Oct 21, 2005
2,001
162
Norway
Thanks for the screenshot which helped find the correct actions.
But I'm scratching my head on where to find "Open timers" and "Start a timer for 10 seconds".
I've tried the "Open Tab (Clock)" action which might be it, but I couldn't figure out the "Shortcut input" options to include "Timers". Nor does the "Open App" action seem to do it.
And for "Start a timer for 10 seconds", it looks like you used the "Start timer" action, but that's obviously not it. o_O
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.