Skip to content

Commit 771dd59

Browse files
authored
fix: resolve interrupted play request (#43)
* init commit * chore: fit player within demo-snippet
1 parent 5acbc8b commit 771dd59

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

demo/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
.centered {
1515
max-width: none;
1616
}
17+
demo-snippet {
18+
width: fit-content;
19+
}
1720
</style>
1821
</custom-style>
1922
</head>

mp4-video-player.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,15 @@ class MP4VideoPlayer extends PolymerElement {
770770
* Play the video
771771
*/
772772
play() {
773-
this._getShadowElementById('video_player').play();
774-
this._setPlaying(true);
775-
this.focus();
773+
const aPromise = this._getShadowElementById('video_player').play();
774+
if (aPromise !== undefined) {
775+
aPromise.then(() => {
776+
this._setPlaying(true);
777+
this.focus();
778+
}).catch(() => {
779+
console.log('Problem Playing Audio!');
780+
});
781+
}
776782
}
777783

778784
/**

0 commit comments

Comments
 (0)