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:
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);