Skip to content

Commit

Permalink
docs: change variable declaration to modern syntax (#2692)
Browse files Browse the repository at this point in the history
Issue #2544
  • Loading branch information
태재영 authored Jun 29, 2020
1 parent c7fcae8 commit dd48cef
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 77 deletions.
2 changes: 1 addition & 1 deletion docs/tutorials/a11y.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ will need to change the aria-label as well.

```js
this.eventManager.listen(this.button_, 'click', () => {
let nextManifest = /* Your logic to pick the next video to be played */
const nextManifest = /* Your logic to pick the next video to be played */
myapp.getNextManifest();

this.player.load(nextManifest);
Expand Down
10 changes: 5 additions & 5 deletions docs/tutorials/ad_monetization.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ const video = document.getElementById('video');
const ui = video['ui'];
// If you're using a non-UI build, this is the div you'll need to create
// for your layout.
var container = video.ui.getControls().getControlsContainer();
const container = video.ui.getControls().getControlsContainer();
adManager.initClientSide(container, video);
```

With the client side logic initialized, you can request ads at any time during
the presentation.

```js
var adsRequest = new google.ima.AdsRequest();
const adsRequest = new google.ima.AdsRequest();
// Your ad tag url should go here. We are using a sample ad tag from the
// IMA HTML5 SDK implementation guide for this tutorial.
adsRequest.adTagUrl = 'https://pubads.g.doubleclick.net/gampad/ads?' +
Expand Down Expand Up @@ -100,7 +100,7 @@ const video = document.getElementById('video');
const ui = video['ui'];
// If you're using a non-UI build, this is the div you'll need to create
// for your layout.
var container = video.ui.getControls().getServerSideAdContainer();
const container = video.ui.getControls().getServerSideAdContainer();
adManager.initServerSide(container, video);
```

Expand All @@ -110,7 +110,7 @@ dynamically inserted ads.
Requesting a VOD stream:

```js
var streamRequest = new google.ima.dai.api.VODStreamRequest();
const streamRequest = new google.ima.dai.api.VODStreamRequest();
// Your stream information will go here. We are using IMA's sample stream info
// in this tutorial.
streamRequest.contentSourceId = '2528370';
Expand All @@ -129,7 +129,7 @@ See [google.ima.dai.api.VODStreamRequest][] for details on the request object.
Requesting a LIVE stream:

```js
var streamRequest = new google.ima.dai.api.LiveStreamRequest();
const streamRequest = new google.ima.dai.api.LiveStreamRequest();
// Your stream information will go here. We are using IMA's sample stream info
// in this tutorial.
streamRequest.assetKey = 'sN_IYUG8STe1ZzhIIE_ksA';
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Basic usage of Shaka Player is very easy:
```js
// myapp.js

var manifestUri =
const manifestUri =
'https://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd';

function initApp() {
Expand All @@ -51,8 +51,8 @@ function initApp() {

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

// Attach player to the window to make it easy to access in the JS console.
window.player = player;
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and make a bad change.
First, let's change `manifestUri` by removing the last letter.

```js
var manifestUri =
const manifestUri =
'https://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mp';
```

Expand Down
22 changes: 11 additions & 11 deletions docs/tutorials/license-server-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ To start, we're going to use the code from {@tutorial basic-usage}, but use this
manifest and license server:

```js
var manifestUri =
const manifestUri =
'https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd';
var licenseServer = 'https://cwip-shaka-proxy.appspot.com/no_auth';
const licenseServer = 'https://cwip-shaka-proxy.appspot.com/no_auth';
```

We'll also need to configure the player to use this license server before it
Expand All @@ -44,7 +44,7 @@ Since the endpoint is `/no_auth`, this should play without authentication.
First, we'll try authentication using headers. Change the license server to:

```js
var licenseServer = 'https://cwip-shaka-proxy.appspot.com/header_auth';
const licenseServer = 'https://cwip-shaka-proxy.appspot.com/header_auth';
```

This endpoint requires a specific header value to deliver a license. If you
Expand Down Expand Up @@ -79,7 +79,7 @@ Next, we'll try authentication using URL parameters. Change the license server
to:

```js
var licenseServer = 'https://cwip-shaka-proxy.appspot.com/param_auth';
const licenseServer = 'https://cwip-shaka-proxy.appspot.com/param_auth';
```

This endpoint requires a specific URL parameter to deliver a license. If you
Expand Down Expand Up @@ -110,7 +110,7 @@ Finally, let's try using cookies for authentication. Change the license server
to:

```js
var licenseServer = 'https://cwip-shaka-proxy.appspot.com/cookie_auth';
const licenseServer = 'https://cwip-shaka-proxy.appspot.com/cookie_auth';
```

This endpoint requires a specific cookie to deliver a license. If you try to
Expand Down Expand Up @@ -161,7 +161,7 @@ pointing your browser to the server's [delete\_cookie][] page. Then set your
license server back to:

```js
var licenseServer = 'https://cwip-shaka-proxy.appspot.com/no_auth';
const licenseServer = 'https://cwip-shaka-proxy.appspot.com/no_auth';
```

Since `allowCrossSiteCredentials` is `true` and that endpoint doesn't
Expand Down Expand Up @@ -194,9 +194,9 @@ of an asynchronous filter.
To start, change the license server and add two additional variables:

```js
var licenseServer = 'https://cwip-shaka-proxy.appspot.com/header_auth';
var authTokenServer = 'https://cwip-shaka-proxy.appspot.com/get_auth_token';
var authToken = null;
const licenseServer = 'https://cwip-shaka-proxy.appspot.com/header_auth';
const authTokenServer = 'https://cwip-shaka-proxy.appspot.com/get_auth_token';
const authToken = null;
```

Now change the request filter:
Expand All @@ -215,11 +215,11 @@ Now change the request filter:

console.log('Need auth token.');
// Start an asynchronous request, and return a Promise chain based on that.
var authRequest = {
const authRequest = {
uris: [authTokenServer],
method: 'POST',
};
var requestType = shaka.net.NetworkingEngine.RequestType.APP;
const requestType = shaka.net.NetworkingEngine.RequestType.APP;
return player.getNetworkingEngine().request(requestType, authRequest)
.promise.then(function(response) {
// This endpoint responds with the value we should use in the header.
Expand Down
24 changes: 12 additions & 12 deletions docs/tutorials/license-wrapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ To start, we're going to use the code from {@tutorial basic-usage}, but use this
manifest and license server:

```js
var manifestUri =
const manifestUri =
'https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd';
var licenseServer = 'https://cwip-shaka-proxy.appspot.com/wrapped_request';
const licenseServer = 'https://cwip-shaka-proxy.appspot.com/wrapped_request';
```

We'll also need to configure the player to use this license server before it
Expand All @@ -64,13 +64,13 @@ license request, we must register a request filter:
```js
player.getNetworkingEngine().registerRequestFilter(function(type, request) {
// Alias some utilities provided by the library.
var StringUtils = shaka.util.StringUtils;
var Uint8ArrayUtils = shaka.util.Uint8ArrayUtils;
const StringUtils = shaka.util.StringUtils;
const Uint8ArrayUtils = shaka.util.Uint8ArrayUtils;

// Only manipulate license requests:
if (type == shaka.net.NetworkingEngine.RequestType.LICENSE) {
// Create the wrapped request structure.
var wrapped = {};
const wrapped = {};

// Encode the raw license request in base64.
// The server we are using in this tutorial expects this field and this
Expand All @@ -89,7 +89,7 @@ license request, we must register a request filter:
wrapped.pEqualsNP = false; // maybe?

// Encode the wrapped request as JSON.
var wrappedJson = JSON.stringify(wrapped);
const wrappedJson = JSON.stringify(wrapped);
// Convert the JSON string back into an ArrayBuffer to replace the request
// body.
request.body = StringUtils.toUTF8(wrappedJson);
Expand Down Expand Up @@ -123,7 +123,7 @@ that looks like this:
Change the license server to:

```js
var licenseServer =
const licenseServer =
'https://cwip-shaka-proxy.appspot.com/wrapped_request_and_response';
```

Expand All @@ -135,18 +135,18 @@ using a request filter:
```js
player.getNetworkingEngine().registerResponseFilter(function(type, response) {
// Alias some utilities provided by the library.
var StringUtils = shaka.util.StringUtils;
var Uint8ArrayUtils = shaka.util.Uint8ArrayUtils;
const StringUtils = shaka.util.StringUtils;
const Uint8ArrayUtils = shaka.util.Uint8ArrayUtils;

// Only manipulate license responses:
if (type == shaka.net.NetworkingEngine.RequestType.LICENSE) {
// This is the wrapped license, which is a JSON string.
var wrappedString = StringUtils.fromUTF8(response.data);
const wrappedString = StringUtils.fromUTF8(response.data);
// Parse the JSON string into an object.
var wrapped = JSON.parse(wrappedString);
const wrapped = JSON.parse(wrappedString);

// This is a base64-encoded version of the raw license.
var rawLicenseBase64 = wrapped.rawLicenseBase64;
const rawLicenseBase64 = wrapped.rawLicenseBase64;
// Decode that base64 string into a Uint8Array and replace the response
// data. The raw license will be fed to the Widevine CDM.
response.data = Uint8ArrayUtils.fromBase64(rawLicenseBase64);
Expand Down
20 changes: 10 additions & 10 deletions docs/tutorials/manifest-parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ MyManifestParser.prototype.configure = function(config) {
};

MyManifestParser.prototype.start = async function(uri, playerInterface) {
var type = shaka.net.NetworkingEngine.RequestType.MANIFEST;
var request = {
const type = shaka.net.NetworkingEngine.RequestType.MANIFEST;
const request = {
uris: [uri],
method: 'GET',
retryParameters: this.config_.retryParameters
Expand Down Expand Up @@ -181,10 +181,10 @@ It handles merging new segments, and expanding the list of segments for live
streams.

```js
var references = refs.map(function(r) {
const references = refs.map(function(r) {
// Should return an array of possible URI choices; this is used for failover
// in the event of network error. This is a function to defer calculations.
var getUris = function() { return [r.uri]; };
const getUris = function() { return [r.uri]; };

return new shaka.media.SegmentReference(
r.start, r.end, getUris,
Expand All @@ -196,7 +196,7 @@ var references = refs.map(function(r) {
/* appendWindowEnd */ Infinity);
});

var index = new shaka.media.SegmentIndex(references);
const index = new shaka.media.SegmentIndex(references);
```

To merge updates, simply create a new array of segments and call `merge`. Any
Expand Down Expand Up @@ -242,7 +242,7 @@ MyManifestParser.prototype.loadManifest_ = function(data) {
// |data| is the response data from load(); but in this example, we ignore it.

// The arguments are only used for live.
var timeline = new shaka.media.PresentationTimeline(null, 0);
const timeline = new shaka.media.PresentationTimeline(null, 0);
timeline.setDuration(3600); // seconds

return {
Expand Down Expand Up @@ -276,11 +276,11 @@ MyManifestParser.prototype.loadVariant_ = function(hasVideo, hasAudio) {
};

MyManifestParser.prototype.loadStream_ = function(type) {
var getUris = function() { return ['https://example.com/init']; };
var initSegmentReference = new shaka.media.InitSegmentReference(getUris,
const getUris = function() { return ['https://example.com/init']; };
const initSegmentReference = new shaka.media.InitSegmentReference(getUris,
/* startByte= */ 0, /* endByte= */ null);

var index = new shaka.media.SegmentIndex([
const index = new shaka.media.SegmentIndex([
// Times are in seconds, relative to the presentation
this.loadReference_(0, 0, 10, initSegmentReference),
this.loadReference_(1, 10, 20, initSegmentReference),
Expand Down Expand Up @@ -321,7 +321,7 @@ MyManifestParser.prototype.loadStream_ = function(type) {

MyManifestParser.prototype.loadReference_ =
function(position, start, end, initSegmentReference) {
var getUris = function() { return ['https://example.com/ref_' + position]; };
const getUris = function() { return ['https://example.com/ref_' + position]; };
return new shaka.media.SegmentReference(
start, end, getUris,
/* startByte */ 0,
Expand Down
Loading

0 comments on commit dd48cef

Please sign in to comment.