diff --git a/common/app/model/dotcomrendering/DotcomRenderingDataModel.scala b/common/app/model/dotcomrendering/DotcomRenderingDataModel.scala index cce1327fef4..22a804d0f9d 100644 --- a/common/app/model/dotcomrendering/DotcomRenderingDataModel.scala +++ b/common/app/model/dotcomrendering/DotcomRenderingDataModel.scala @@ -10,7 +10,7 @@ import conf.Configuration import crosswords.CrosswordPageWithContent import experiments.ActiveExperiments import model.dotcomrendering.DotcomRenderingUtils._ -import model.dotcomrendering.pageElements.{ImageBlockElement, PageElement, Role, TextCleaner} +import model.dotcomrendering.pageElements.{AudioBlockElement, ImageBlockElement, PageElement, Role, TextCleaner} import model.liveblog.BlockAttributes import model.{ ArticleDateTimes, @@ -544,12 +544,24 @@ object DotcomRenderingDataModel { ) } - val mainMediaElements = - mainBlock + val mainMediaElements = { + val pageElements = mainBlock .map(toDCRBlock(isMainBlock = true)) .toList .flatMap(_.elements) + page.metadata.contentType match { + case Some(DotcomContentType.Audio) => + pageElements + .map { + case AudioBlockElement(assets, _) => + AudioBlockElement(assets, Option(content.elements.mainAudio.head.properties.id)) + case pageElement => pageElement + } + case _ => pageElements + } + } + val bodyBlocksDCR = bodyBlocks .filter(_.published || pageType.isPreview) // TODO lift? diff --git a/common/app/model/dotcomrendering/pageElements/PageElement.scala b/common/app/model/dotcomrendering/pageElements/PageElement.scala index 5495f7ebe01..acada40bd1e 100644 --- a/common/app/model/dotcomrendering/pageElements/PageElement.scala +++ b/common/app/model/dotcomrendering/pageElements/PageElement.scala @@ -120,7 +120,7 @@ object AudioAtomBlockElement { // We are currently using AudioBlockElement as a catch all for audio errors, skipping the first definition // See comment: 2e5ac4fd-e7f1-4c04-bdcd-ceadd2dc5d4c -case class AudioBlockElement(assets: Seq[AudioAsset]) extends PageElement +case class AudioBlockElement(assets: Seq[AudioAsset], id: Option[String] = None) extends PageElement object AudioBlockElement { implicit val AudioBlockElementWrites: Writes[AudioBlockElement] = Json.writes[AudioBlockElement] }