Search code examples
hbbtv

How is `switchMediaPresentation` used?


It's not clear to me how is switchMediaPresentation supposed to work after reading the docs: https://www.hbbtv.org/wp-content/uploads/2021/07/HbbTV-SPEC-00260-030-ts_103464v010301-without-ETSI-branding.pdf

I'm trying the following:

// ... previous code

<object type="application/hbbtvMediaSwitcher" class="MediaSwitcher" id="MediaSwitcher"></object>

// ... More code

<script>
  document
    .getElementById("MediaSwitcher")
    .switchMediaPresentation(
      originalMediaObject,
      newMediaObject,
    )
    .then(() => {})
    .catch(e => {})
</script>

I'm getting error document.getElementById(...).switchMediaPresentation is not a function

Any idea from my fellow HbbTV developers?


Solution

  • Are you sure the device supports switchMediaPresentation and that it's enabled for you? That API is very new, there aren't many implementations and the most widespread one only enables the feature for specific apps.