diff --git a/components/app/AudioPlayer.vue b/components/app/AudioPlayer.vue index 516c9c12..d9f178c8 100644 --- a/components/app/AudioPlayer.vue +++ b/components/app/AudioPlayer.vue @@ -30,7 +30,7 @@ -
+
@@ -109,6 +109,7 @@ export default { }, data() { return { + windowHeight: 0, playbackSession: null, showChapterModal: false, showFullscreen: false, @@ -138,6 +139,11 @@ export default { dragPercent: 0 } }, + watch: { + showFullscreen() { + this.updateScreenSize() + } + }, computed: { menuItems() { var items = [] @@ -157,10 +163,15 @@ export default { return this.$store.getters['getBookCoverAspectRatio'] }, bookCoverWidth() { + if (this.showFullscreen) return this.fullscreenBookCoverWidth + return 60 + }, + fullscreenBookCoverWidth() { + var heightScale = (this.windowHeight - 200) / 651 if (this.bookCoverAspectRatio === 1) { - return this.showFullscreen ? 260 : 60 + return 260 * heightScale } - return this.showFullscreen ? 200 : 60 + return 200 * heightScale }, showCastBtn() { return this.$store.state.isCastAvailable @@ -679,15 +690,28 @@ export default { this.onPlaybackFailedListener = AbsAudioPlayer.addListener('onPlaybackFailed', this.onPlaybackFailed) this.onPlayingUpdateListener = AbsAudioPlayer.addListener('onPlayingUpdate', this.onPlayingUpdate) this.onMetadataListener = AbsAudioPlayer.addListener('onMetadata', this.onMetadata) + }, + screenOrientationChange() { + setTimeout(this.updateScreenSize, 50) + }, + updateScreenSize() { + this.windowHeight = window.innerHeight + var coverHeight = this.fullscreenBookCoverWidth * this.bookCoverAspectRatio + document.documentElement.style.setProperty('--cover-image-width', this.fullscreenBookCoverWidth + 'px') + document.documentElement.style.setProperty('--cover-image-height', coverHeight + 'px') } }, mounted() { + this.updateScreenSize() + screen.orientation.addEventListener('change', this.screenOrientationChange) document.body.addEventListener('touchstart', this.touchstart) document.body.addEventListener('touchend', this.touchend) document.body.addEventListener('touchmove', this.touchmove) this.$nextTick(this.init) }, beforeDestroy() { + screen.orientation.removeEventListener('change', this.screenOrientationChange) + if (this.playbackSession) { console.log('[AudioPlayer] Before destroy closing playback') this.closePlayback() @@ -709,6 +733,13 @@ export default {