Spotify Play Button in ePub 3.0 eBook

5 posts / 0 new
Last post

I just started using InDesign CS6, CS6, Sigil, TextWrangler and ePub Zip-Unzip on a Mac Pro to produce an ePub 3.0 eBook. I would like "something-like" a Spotify Play Button but for ePub 3.0 eBooks, not for a Web site. I wish to add code for this Spotify Play Button to the ePub 3.0 eBook allowing play of a Spotify sound track either by streaming over the internet or via tracks previously downloaded to on an iPad. From what I've read about ePub 3.0 (HTML5 for Publishers by Sandy Kleinfeld and EPUB 3 Best Practices by Garrish & Gylling), it seems that an <iframe/> is no good for ePub 3.0. I have some good reference books (Liz Castro, Matt Garish, Sanders Kleinfeld) to use as resources.

Do you have any suggestions?



Background Info: The Spotify Play Button uses an <iframe/> to play Spotify audio tracks (songs) on a website. The Play Button streams the spotify:track or playlist specified in the Embed Code from the Spotify cleint.

It's not so much the iframe itself, but pulling in content from out on the Web, or from the local file system.

Right now, the only resources that can legitimately live outside the container are audio and video, but what sometimes trips people up is that an audio or video resource embedded within a page (or that needs to be called via an html player) does not mean you can by extension pull in that page. That's where I would see your problem lying, as spotify doesn't provide specific audio/* or video/* media type resources, but renders the html player in the iframe.

I know people try to hack around this limitation via JavaScript, and by faking media types in the manifest, but what I keep having to point out is that a hack is always a hack, and not only will it not work on all reading systems right now, but the ones where it does work you have to keep in mind that the developers may close the loop on you at any point.

I'm of two minds on this myself, as I'd love to see the flexibility while fully acknowledging that there are implications to throwing open the barn door to anything on the Web. Security is one consideration, of course (especially on the local file system), but so is the very nature of EPUB as a reliable packaging of content. If your content can come from anywhere (i.e., a distributed publication), you have to be aware that the consumers of your publication are not all going to be able to render it, and there's also the issue as a consumer that your book may change each time it's opened, and even that content you once had may go dead if the site it's hosted on goes under.

One thought has been to be more lenient but only within the confines of an iframe and the restrictions that can be placed on it relative to what the embedded content can do (and potentially noting that it must not contain any of the primary narrative, although that is covered by the specs right now).

But that future isn't here now, so, almost needless to say, all I can tell you is to hack at your peril, knowing that iBooks and others are going to block the content.

Sorry I can't be any more helpful here than I was in the book, but them's just the way things is...

Thank you Matt for your extensive and knowledgeable response. I don't understand why iBooks (mean iTunes?) and others would block the content? Is it because Spotify is competition?

Re-statement of question for ideal solution: 1. How can one, elegantly and conveniently for the the reader (the person not the device), place a transport button in an epub eBook linked (via Wi-Fi on an iPad) to a Spotify:track at the Spotify Website (streamed from the client)? Tap the button to play and tap the button to stop. No wandering here or there by the reader! 2. How can one, elegantly and conveniently for the reader, place a transport button in an epub eBook linked to a Spotify:track previously downloaded to on the iPad?

I discovered that the Spotify Play Button wasn't so great after all on my iPad. I placed the following on the Spotify Community two days ago: When I tap a Spotify Play Button on a website in Safari on my Mac Pro (with open in the background), the track plays, the pause button appears and I stay on the same page (as it should). However when I tap a Spotify Play Button on a website in Safari on my mini-iPad (iOS 6.1.3), the track plays, the webpage closes, opens and the track plays there. I have to press Home Button, tap Safari to get back to the Website where there is no pause button. To stop the track, I have to go to, stop and return again to the Website in Safari. Is this the way it is supposed to be? Any suggestions to get this to work as it does on the Mac? I got the following answer: This is because the website is coded to tell the device to launch Spotify to play the track. So yes that is how it should be, as there isn't an online play feature yet. Anthony. In my words, the has to open each time.

Of course what one wants is to use a transport button in the eBook and stay there and not go wandering around. The use of a Spotify Play Button on the iPad is not much more convenient than the following solution which actually works now.

Links in ePub (eBook) to
Spotify Playlist or Tracks

Create ePub on Mac

Open on Mac
Right click on Playlist or track in Spotify and select copy HTTP link
Paste link in Word and then place in InDesign CS6
Export to ePub.
Add to Library in iTunes. Sync to iPad.

Play tracks in ePub on iPad using Wi-Fi

Wi-Fi On
Install Spotify app on iPad
Tap iBooks app and then ePub
Tap on link to play
Tap on Play button in Spotify, Track Plays
Press Home Button on iPad
Tap on iBooks app
Stop Play - press Home Button
Tap and then Pause Button
Press Home Button, tap

Play Playlist in ePub on iPad using W-Fi

Wi-Fi On
Install Spotify app on iPad
Tap iBooks app and then ePub
Tap on link to Playlist
Tap on Play button, Tap on desired Track to play, Track Plays
Press Home Button on iPad
Tap on iBooks app
To Stop Play - press Home Button, Tap, tap Pause Button, Press Home Button, tap
Playlist will stay open in Spotify, select and pause tracks as desired

Play Tracks in ePub on iPad using Playlist stored on iPad (Wi -Fi not needed, Premium Spotify Account Required)

Sync the playlist to iPad

iPad WiFi: ON
Tap on Spotify, log-in
Spotify Settings, Offline Mode: Off
Press Home Button, Tap on ePub, Tap on link to Garden by the Water Playlist
Tap on Playlist and the Garden Playlist
Tap on the download button and swipe the switch to YES
downloaded tracks will be marked with the green 'Download' badge.

Play Tracks

Spotify Settings, Playback, Offline Mode: ON
iPad WiFi: OFF, no USB cable from Mac to iPad
Tap Spotify app and Playlist
Press Home Button, Tap iBooks app and then ePub to open
When desire to play track (can’t use links in eBook), press Home Button, Tap Spotify, Tap on track (will play)
Press Home Button, Tap on iBooks app
To Stop Play - press Home Button, Tap, tap Pause Button, Press Home Button, tap

Playlist will stay open in Spotify, select and pause tracks as desired

This works but is awkward and inelegant. Of course, Spotify can change things whenever. Any problems other than this? Any way to streamline this sort of simple linking operation?



Just to reiterate, it's nothing to do with competition; it's a requirement of the epub specification. Resources other than audio and video are not allowed to be pulled in, so if you find a reading systems that does allow other content it is actually not compliant with the specification. There is also no requirement in epub that a reading system with scripting support allow unfettered access to the network. iBooks, and others, are simply adhering to these guidelines.

That's why elegant solutions are going to be hard to come by until such time as there is agreement to further loosen the restrictions and/or expand what can live outside the epub container.

Progressive enhancement is the only suggestion I can give, which seems to be your inelegant solution. Start with a link that would launch spotify in an external window, and if scripting and network access are available try to write the spotify iframe into the epub instead.


one year after has anyone succeeded in including Spotify play button in an epub 3 page ? This could be really useful to play music and sounds without the hassles of rights and files weight. if ePub and IDPF don't move this way (ie possibility to have music streaming, I mean more than just text and embedded media files like in the 90's CD-Roms) guess W3C which is working on electronic books for web will definitely kill epub 3, 2, you name it.


François Luc

Secondary menu