try/catch in aspect ratio getter

This commit is contained in:
Tamius Han 2021-04-12 19:01:28 +02:00
parent 0bed840b6f
commit 60f940f4db
2 changed files with 15 additions and 5 deletions

View File

@ -72,11 +72,16 @@ class PlayerData {
* Gets player aspect ratio. If in full screen, it returns screen aspect ratio unless settings say otherwise.
*/
get aspectRatio() {
if (this.dimensions.fullscreen && !this.settings.getSettingsForSite()?.usePlayerArInFullscreen) {
return window.innerWidth / window.innerHeight;
}
try {
if (this.dimensions?.fullscreen && !this.settings.getSettingsForSite()?.usePlayerArInFullscreen) {
return window.innerWidth / window.innerHeight;
}
return this.dimensions.width / this.dimensions.height;
return this.dimensions.width / this.dimensions.height;
} catch (e) {
console.error('cannot determine aspect ratio!', e);
return 1;
}
}
constructor(videoData) {

View File

@ -49,7 +49,12 @@ class VideoData {
get aspectRatio() {
return this.video.videoWidth / this.video.videoHeight;
try {
return this.video.videoWidth / this.video.videoHeight;
} catch (e) {
console.error('cannot determine stream aspect ratio!', e);
return 1;
}
}
constructor(video, settings, pageInfo){