docs: change promise then to await (#2693)

Closes #2544
This commit is contained in:
태재영
2020-06-30 06:24:23 +09:00
committed by GitHub
parent dd48cef08f
commit 7ab9031248
4 changed files with 23 additions and 12 deletions
+7 -3
View File
@@ -49,7 +49,7 @@ function initApp() {
}
}
function initPlayer() {
async function initPlayer() {
// Create a Player instance.
const video = document.getElementById('video');
const player = new shaka.Player(video);
@@ -62,10 +62,14 @@ function initPlayer() {
// Try to load a manifest.
// This is an asynchronous process.
player.load(manifestUri).then(function() {
try {
await player.load(manifestUri);
// 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.
} catch (e) {
// onError is executed if the asynchronous load fails.
onError(e);
}
}
function onErrorEvent(event) {