Files
shaka-player/tutorials/sample4.txt
T
Joey Parrish 03964e4c84 Drop suppressMultipleEvents from DrmSchemeInfo.
This interfered with key rotation, and was not widely used.  Removing
the feature is the more general approach, and the worst that will
happen is that some applications will see more sessions than they
strictly need.

Change-Id: Ide2238433af296e729e4401711672fb17257093e
2015-04-09 19:31:34 +00:00

83 lines
3.0 KiB
Plaintext

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>TurtleTube - Encrypted Content</title>
<!-- Load the Shaka Player library. -->
<script src="shaka-player.compiled.js"></script>
</head>
<body>
<video id="video"
width="640" height="480"
crossorigin="anonymous"
controls autoplay>
Your browser does not support HTML5 video.
</video>
</body>
<script>
function initPlayer() {
// Install polyfills.
shaka.polyfill.Fullscreen.install();
shaka.polyfill.MediaKeys.install();
shaka.polyfill.VideoPlaybackQuality.install();
// Find the video element.
var video = document.getElementById('video');
// Construct a Player to wrap around it.
var player = new shaka.player.Player(video);
// Attach the player to the window so that it can be easily debugged.
window.player = player;
// Listen for errors from the Player.
player.addEventListener('error', function(event) {
console.error(event);
});
// Construct a DashVideoSource to represent the DASH manifest and provide
// a callback to interpret the ContentProtection elements.
var mpdUrl = 'http://turtle-tube.appspot.com/t/e6/dash.mpd';
var estimator = new shaka.util.EWMABandwidthEstimator();
var source = new shaka.player.DashVideoSource(mpdUrl,
interpretContentProtection,
estimator);
// Load the source into the Player.
player.load(source);
}
/**
* @param {!shaka.dash.mpd.ContentProtection} contentProtection The
* ContentProtection element from the MPD.
* @return {shaka.player.DrmSchemeInfo} or null if the element is not
* understood by this application.
*/
function interpretContentProtection(contentProtection) {
// This is the UUID which is used by edash-packager to represent
// Widevine. This is the only scheme we are expecting for this
// application.
if (contentProtection.schemeIdUri ==
'urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed') {
// We will use Widevine's testing license server. In a real app,
// you would run your own front-end service for this.
var licenseServerUrl = 'http://widevine-proxy.appspot.com/proxy';
// The EME key system identifier for Widevine.
var keySystem = 'com.widevine.alpha';
return new shaka.player.DrmSchemeInfo(keySystem,
licenseServerUrl,
false /* withCredentials */,
null /* initData */,
null /* licensePostProcessor */);
}
console.warn('Unrecognized scheme: ' + contentProtection.schemeIdUri);
return null;
}
document.addEventListener('DOMContentLoaded', initPlayer);
</script>
</html>