[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook] audio epubs
[Replying to docbook-apps where this belongs...] On 18.9.2014 15:38, Peter Fleck wrote:Is it possible to do a lot of the work to make audio epubs using stylesheets?Everything is possible, it depends on effort you can put into it :-)First, how to auto generate ids for each <para>? I'm sure that is straightforward. (Or if more granularity is needed then id's at the sentence or word level as needed).Putting following into your customization layer should do the trick: <xsl:param name="generate.id.attributes" select="1"/> <xsl:param name="generate.consistent.ids" select="1"/> <xsl:template name="id.attribute"> <xsl:param name="node" select="."/> <xsl:param name="conditional" select="0"/> <xsl:choose> <xsl:when test="$generate.id.attributes = 0"> <!-- No id attributes when this param is zero --> </xsl:when> <xsl:when test="$conditional = 0 or $node/@id or $node/@xml:id"> <xsl:attribute name="id"> <xsl:call-template name="object.id"> <xsl:with-param name="object" select="$node"/> </xsl:call-template> </xsl:attribute> </xsl:when> </xsl:choose> </xsl:template> However if you change your DocBook source autogenerated IDs will change.Second, populate the smil file with the ids <smil xmlns="http://www.w3.org/ns/SMIL" xmlns:epub="http://www.idpf.org/2007/ops" version="3.0"> <body> <seq id="id1" epub:textref="index.xhtml" epub:type="bodymatter chapter"> <par id="paragraph1"> <text src=""/> <audio src="" clipBegin="0:00:02.000" clipEnd="0:00:15.000"/> </par> <par id="paragraph2"> <text src=""/> <audio src="" clipBegin="0:00:15.000" clipEnd="0:00:25.000"/> </par> .... </seq> </body> </smil> The smil file would need manually editing for the clipBegin and clipEnd for each but that's fine. The audio src could be passed as a parameter. Then add something like .-epub-media-overlay-active {background-color: #abc;} to the css.Have you considered generating this SMIL file automatically? I can imagine putting custom attributes into DocBook document, something like: <chapter my:audio="file.mp3"> <title>Foo</title> <para my:begin="0:00:02.000" my:end="0:00:15.000">...</para> <para my:begin="0:00:15.000" my:end="0:00:25.000">...</para> ... From such markup you can quite easily generate SMIL file automatically.Finally modify the package.opf to add <meta property="media:duration" refines="#chapter1_overlay">0:04:30.000</meta> <meta property="media:duration" refines="#chapter2_overlay">0:03:30.000</meta> .... <meta property="media:duration">0:08:00.000</meta> <meta property="media:narrator">Narrator Name</meta> <meta property="media:active-class">-epub-media-overlay-active</meta> </metadata> <manifest> <item id="ncx" href="" media-type="application/x-dtbncx+xml"/> <item id="htmltoc" properties="nav" media-type="application/xhtml+xml" href=""/> <item media-type="text/css" id="docbook-css" href=""/> <item id="id-idm21776" href="" media-type="application/xhtml+xml" media-overlay="chapter1_overlay"/> <item id="chapter1_overlay" href="" media-type="application/smil+xml"/> .... Is something like this doable?Yes, generation of OPF file is split into set of relative small templates which you can easily override. Look into epub3/epu3-element-mods.xsl file. For example metadata part is generated by the following template: <xsl:template name="package.metadata"> <xsl:element name="metadata" namespace="{$opf.namespace}"> <xsl:call-template name="metadata.identifier"/> <xsl:call-template name="metadata.title"/> <xsl:call-template name="metadata.language"/> <xsl:call-template name="metadata.modified"/> <xsl:call-template name="metadata.cover"/> <xsl:call-template name="metadata.other.info"/> </xsl:element> </xsl:template> You can generate this template manually, or put your custom elements inside <info> elements and handle them in special opf.metadata mode. <info> ... <media:narrator>Narrator Name</media:narrator> </info> <xsl:template match="media:*" mode="opf.metadata"> <meta property="media:{local-name(.)}"><xsl:value-of select="."/></meta> </xsl:template> HTH, Jirka |
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]