0

我想要的只是让我的 shaka-player 工作。我已经列出了我的电影目录中的所有文件。我的清单文件 (.mpd) 由位于同一目录中的 5 个不同的 webm 视频流文件组成(我意识到音频不存在,这在这种情况下并不重要)。

我几乎按照网站上的教程进行操作:

https://shaka-player-demo.appspot.com/docs/api/tutorial-welcome.html

我不确定为什么这不起作用。有人可以帮忙吗?

电影目录:

Movie_WebM.html  
shaka-player.compiled.js  
Movie.js  
Movie_Manifest.mpd              
Movie_160x90_250k.webm                           
Movie_320x180_500k.webm  
Movie_640x360_1000k.webm  
Movie_640x360_750k.webm     
Movie_1280x720_500k.webm

Movie_WebM.html:

<!DOCTYPE html>
<html>
  <head>
    <script src="shaka-player.compiled.js"></script>
    <script src="Movie.js"></script>
  </head>
  <body>
    <video id="video"
           width="640"
           poster="//shaka-player-demo.appspot.com/assets/poster.jpg"
           controls></video>
  </body>
</html>

电影.js:

var manifestUri = 'Movie_Manifest.mpd';

function initApp() {
  shaka.log.setLevel(shaka.log.Level.V1);
  // 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);

  // 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);
4

1 回答 1

0

尝试在本地主机上运行。您可以使用 Python SimpleHTTPServer:

python -m SimpleHTTPServer

并打开

localhost:8000/{MOVIE_DIR}/Movie_WebM.html

EME 需要一个安全的 URL 才能使用。这意味着您必须使用 https 或在本地主机上。目前只有 Chrome 强制执行,但其他浏览器将在未来执行。此外,由于混合内容要求,如果您的网站使用 https,那么您的清单和每个段也需要使用 https。- https://shaka-player-demo.appspot.com/docs/api/tutorial-drm-config.html

于 2017-08-23T11:55:17.003 回答