Playing encrypted media

Sometimes, playing immersive audio as encrypted media works better.

Yes, you heard that right. Sometimes, playing unencrypted Dolby Atmos comes out as a stereo downmix, and it helps to play encrypted media instead. The reason that one works better than the other is that encrypted media takes a rather different path through the media pipeline. [1] The encrypted pipeline is tailored towards premium experiences and therefore has support for Dolby Atmos more often than not.

Encrypting the media is typical of digital rights management (DRM) setups. In this example however, we won't build a full-blown DRM player, since our purpose is not to keep the assets secure, but to exercise a different media path. For this, it is usually sufficient to use the encrypted media extensions (EME) API, and to use a mode known as clear-key. In this mode, the media is encrypted, but it comes with the key to decrypt it.

Here are the relevant parts:

Figure 1. Playing back encrypted Dolby Atmos content
const protData = {
    "org.w3.clearkey": {
        "clearkeys": {
            "nrQFDeRLSAKTLifXUIPiZg": "FmY0xnWCPCNaSpRG-tUuTQ"
        }
    }
};
var videoElement =  document.querySelector('video');
var url = "media/v01/dash_drm/all_clearkey.mpd";
var player = dashjs.MediaPlayer().create();


player.initialize();
player.setAutoPlay(true);
player.attachView(videoElement);

player.setProtectionData(protData);

player.attachSource(url);
[1] In essence, since encryption is usually deployed for protecting the media, the encrypted bits are shipped off to a shielded part of the system that normal processes can't get to; never to be seen again by the sender.