The init segment to ensure is encrypted.
Optionaloptions: Partial<EnsureEncryptedInitOptions>The options for the encryption.
The encrypted init segment.
const original = new Uint8Array(hexToArrayBuffer(`0000001866747970646173680000000069736f366d703431000002bb6d6f6f760000006c6d76686400000000e40fc711e40fc7110000bb80001630000001000001000000000000000000000000010000000000000000000000000000000100000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002000000286d7665780000002074726578000000000000000100000001000000000000000000000000000001c47472616b0000005c746b686400000003e40fc711e40fc711000000010000000000163000000000000000000000000000010000000001000000000000000000000000000000010000000000000000000000000000400000000000000000000000000001606d646961000000206d64686400000000e40fc711e40fc7110000bb800016300055c400000000004768646c720000000000000000736f756e00000000000000000000000049534f204d656469612066696c652070726f647563656420627920476f6f676c6520496e632e00000000f16d696e660000002464696e660000001c6472656600000000000000010000000c75726c2000000001000000b57374626c00000069737473640000000000000001000000596d703461000000000000000100000000000000000002001000000000bb8000000000003565736473000000000327000100041f401500000000000000000000000510119000000000000000000000000000000601020000001073747473000000000000000000000010737473630000000000000000000000107374636f0000000000000000000000147374737a00000000000000000000000000000010736d686400000000000000000000005b75647461000000536d657461000000000000002168646c7200000000000000006d6469726170706c00000000000000000000000026696c73740000001ea9746f6f00000016646174610000000100000000476f6f676c65`))
const modified = new Uint8Array(hexToArrayBuffer(`0000001866747970646173680000000069736f366d703431000003646d6f6f760000006c6d76686400000000e40fc711e40fc7110000bb80001630000001000001000000000000000000000000010000000000000000000000000000000100000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002000000286d76657800000020747265780000000000000001000000010000000000000000000000000000026d7472616b0000005c746b686400000003e40fc711e40fc711000000010000000000163000000000000000000000000000010000000001000000000000000000000000000000010000000000000000000000000000400000000000000000000000000002096d646961000000206d64686400000000e40fc711e40fc7110000bb800016300055c400000000004768646c720000000000000000736f756e00000000000000000000000049534f204d656469612066696c652070726f647563656420627920476f6f676c6520496e632e000000019a6d696e660000002464696e660000001c6472656600000000000000010000000c75726c20000000010000015e7374626c00000112737473640000000000000002000000a9656e6361000000000000000100000000000000000002001000000000bb8000000000003565736473000000000327000100041f401500000000000000000000000510119000000000000000000000000000000601020000005073696e660000000c66726d616d703461000000147363686d0000000063656e630001000000000028736368690000002074656e63000000000000010800000000000000000000000000000000000000596d703461000000000000000100000000000000000002001000000000bb8000000000003565736473000000000327000100041f401500000000000000000000000510119000000000000000000000000000000601020000001073747473000000000000000000000010737473630000000000000000000000107374636f0000000000000000000000147374737a00000000000000000000000000000010736d686400000000000000000000005b75647461000000536d657461000000000000002168646c7200000000000000006d6469726170706c00000000000000000000000026696c73740000001ea9746f6f00000016646174610000000100000000476f6f676c650000001866747970646173680000000069736f366d703431000002bb6d6f6f760000006c6d76686400000000e40fc711e40fc7110000bb80001630000001000001000000000000000000000000010000000000000000000000000000000100000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002000000286d7665780000002074726578000000000000000100000001000000000000000000000000000001c47472616b0000005c746b686400000003e40fc711e40fc711000000010000000000163000000000000000000000000000010000000001000000000000000000000000000000010000000000000000000000000000400000000000000000000000000001606d646961000000206d64686400000000e40fc711e40fc7110000bb800016300055c400000000004768646c720000000000000000736f756e00000000000000000000000049534f204d656469612066696c652070726f647563656420627920476f6f676c6520496e632e00000000f16d696e660000002464696e660000001c6472656600000000000000010000000c75726c2000000001000000b57374626c00000069737473640000000000000001000000596d703461000000000000000100000000000000000002001000000000bb8000000000003565736473000000000327000100041f401500000000000000000000000510119000000000000000000000000000000601020000001073747473000000000000000000000010737473630000000000000000000000107374636f0000000000000000000000147374737a00000000000000000000000000000010736d686400000000000000000000005b75647461000000536d657461000000000000002168646c7200000000000000006d6469726170706c00000000000000000000000026696c73740000001ea9746f6f00000016646174610000000100000000476f6f676c65`))
const result = ensureEncryptedInit(original, { prepend: true, includeOriginal: true })
equal(Buffer.compare(result, modified), 0)
Ensures that the init segment is encrypted. Used on platforms that have issues playing unencrypted content before playing encrypted content. Both prepend and includeOriginal are optional.