Как узнать сейчас, чтобы передать ContentProtectionCallback в SHAKA PLAYER? - PullRequest
0 голосов
/ 16 октября 2018

Может ли кто-нибудь помочь мне узнать сейчас, чтобы передать ContentProtectionCallback, чтобы я мог обработать preProcessor URL-адрес лицензии drm в плеере шака

[http://v1 -6-2.shaka-player-demo.appspot.com/docs/tutorial-network.html][1]

var manifestUri =
    '<mpd url>';

function initApp() {
    // Install built-in polyfills to patch browser incompatibilities.
    shaka.polyfill.installAll();

    // Check to see if the browser supports the basic APIs Shaka needs.
    if (shaka.Player.isBrowserSupported()) {
        // Everything looks good!
        initPlayer();
    } else {
        // This browser does not have the minimum set of APIs we need.
        console.error('Browser not supported!');
    }
}

function initPlayer() {
    // Create a Player instance.
    var video = document.getElementById('video');

    var player = new shaka.Player(video);
    player.configure({
        drm: {
            servers: {
                'com.widevine.alpha': '<server url>',
            }
        }
    });

    // Attach player to the window to make it easy to access in the JS console.
    window.player = player;

    // Listen for error events.
    player.addEventListener('error', onErrorEvent);

    // Try to load a manifest.
    // This is an asynchronous process.
    player.load(manifestUri).then(function () {
        // This runs if the asynchronous load is successful.
        console.log('The video has now been loaded!');
    }).catch(onError);  // onError is executed if the asynchronous load fails.
}

function onErrorEvent(event) {
    // Extract the shaka.util.Error object from the event.
    onError(event.detail);
}

function onError(error) {
    // Log the error.
    console.error('Error code', error.code, 'object', error);
}

document.addEventListener('DOMContentLoaded', initApp);

  [1]: http://v1-6-2.shaka-player-demo.appspot.com/docs/tutorial-network.html

1 Ответ

0 голосов
/ 18 октября 2018

Пожалуйста, прочтите этот учебник .На этой странице объясняется, как обрабатывать лицензию до или после запроса.Я предполагаю, что ContentProtectionCallback - это обработчик для манипулирования запросом лицензии перед его отправкой на сервер.Для этого случая:

  player.getNetworkingEngine().registerRequestFilter(function(type, request) {
    // Manipulate request before is sent.
    if (type == shaka.net.NetworkingEngine.RequestType.LICENSE) {
      const body = request.body;
      // Do something with the body. Then, assign it back.
      request.body = manipulateBody(body)
    }
  });

Вы также можете применить тот же процесс к ответу, используя registerResponseFilter метод

...