# 4K streaming

Tip: open your browser's developer console and use the `player` and `THEOplayer` variables to interact with this demo.

| Active video quality | Press play to start |
| -------------------- | ------------------- |
| Frame rate           | -                   |
| Bitrate              | -                   |

This example plays a 4K Ultra HD (3840×2160) MPEG-DASH stream using Open Video UI. The player uses adaptive bitrate streaming to pick the best quality that your network and device can handle, and switches to the 4K quality when enough bandwidth is available. You can also select a quality manually from the settings menu in the player.

The box below the player shows the quality that is currently playing, using the `activequalitychanged` event of the active video track.

By default, the player limits quality to the rendered player size only on mobile devices. Set `abr: { restrictToPlayerSize: true }` to apply this limit on all devices. Set `abr: { restrictToPlayerSize: false }` to allow larger qualities. Set `abr` on a typed source or in the player configuration. See [`restrictToPlayerSize`](https://docs-preview.optiview.dolby.com/pr-894/theoplayer/v11/api-reference/web/interfaces/SourceAbrConfiguration#restrictToPlayerSize).

```js
player.source = {
  sources: {
    src: 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd',
    type: 'application/dash+xml',
    abr: { restrictToPlayerSize: true },
  },
};
```

> **Tip**
>
> To play 4K content, your device must be able to decode it and your screen should be large enough to show it. Enter fullscreen for the best experience.

Code

demo.html

```html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>4K streaming</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet" />
    <style>
      html,
      body {
        margin: 0;
        padding: 0;
      }

      theoplayer-default-ui:not(:defined) {
        display: inline-block;
        box-sizing: border-box;
      }

      theoplayer-default-ui {
        width: 100%;
        aspect-ratio: 16 / 9;
        font-family: 'Noto Sans', sans-serif;
        background: #000;
      }
    </style>
    <script src="https://cdn.theoplayer.com/dash/theoplayer/THEOplayer.js"></script>
    <script nomodule src="https://unpkg.com/@theoplayer/web-ui@2/polyfills"></script>
    <script async src="https://unpkg.com/@theoplayer/web-ui@2"></script>
  </head>
  <body>
    <!--
      libraryLocation: For demonstration purposes, we use the theoplayer.com CDN.
      For production use, we recommend hosting THEOplayer yourself
      and changing this (as well as the <script> tags above)
      to point to THEOplayer's location on your own website.

      licenseUrl: Change this to point to your THEOplayer license file.
      Alternatively, replace it with a "license" property whose value is your THEOplayer license itself.
    -->
    <theoplayer-default-ui
      configuration='{"libraryLocation":"https://cdn.theoplayer.com/dash/theoplayer/","licenseUrl":"../../../../theoplayer-license.txt"}'
      source='{"sources":{"src":"https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd","type":"application/dash+xml"},"poster":"https://cdn.theoplayer.com/video/big_buck_bunny/poster-alt3.jpg","metadata":{"title":"Big Buck Bunny (4K)"}}'
    ></theoplayer-default-ui>
    <script src="../utils.js"></script>
    <script>
      onPlayerReady((player) => {
        // Report the quality of the video track that is currently playing.
        function reportActiveQuality() {
          const track = Array.from(player.videoTracks).find((track) => track.enabled);
          const quality = track && track.activeQuality;
          console.log('Active video quality', quality);
          sendToParent('activequality', {
            quality: quality && { width: quality.width, height: quality.height, bandwidth: quality.bandwidth, frameRate: quality.frameRate },
          });
        }

        player.videoTracks.addEventListener('addtrack', (event) => {
          event.track.addEventListener('activequalitychanged', reportActiveQuality);
        });
      });
    </script>
  </body>
</html>
```
