videojs / videojs-contrib-eme

Supports Encrypted Media Extensions for playback of encrypted content in Video.js
Other
203 stars 72 forks source link

How to get initData in Clearkey #123

Closed fancofang closed 4 years ago

fancofang commented 4 years ago

Hi, I used the example you gave, it worked. The origin example:

player.src({
        src: '/moose_encrypted.webm',
        type: 'video/webm',
        keySystems: {
          'org.w3.clearkey': {
            audioContentType: 'audio/webm; codecs="vorbis"',
            videoContentType: 'video/webm; codecs="vp8"',
            getLicense: function (emeOptions, keyMessage, callback) {
            ...

But when I try to change the src to cloud url, it doesn't work even it`s the same encrypted video. I can't get the InitData in 'encrypted' event.

 player.src({
        src: 'https://m3u8video.s3.eu-west-2.amazonaws.com/testeme/moose_encrypted.webm',
        type: 'video/webm',
        keySystems: {
          'org.w3.clearkey': {
            audioContentType: 'audio/webm; codecs="vorbis"',
            videoContentType: 'video/webm; codecs="vp8"',
            getLicense: function (emeOptions, keyMessage, callback) {
            ...

Is there anything I get wrong? The Cloud url is public, please feel free to try it. Thank you.

fancofang commented 4 years ago

I fix it already.

There is a rule about initData

The initData attribute will be null if the media data is not CORS-same-origin or is mixed content. Applications may retrieve the Initialization Data from an alternate source.

So, I set crossorigin="same-origin" in