Skip to content

Commit 754b4fb

Browse files
Merge pull request #1804 from nextcloud/fix/video-fullscreen-iPhone-stable25
[stable25] Fix: video player unusable on ios
2 parents 6c09dd6 + 4625331 commit 754b4fb

File tree

9 files changed

+47
-22
lines changed

9 files changed

+47
-22
lines changed

js/viewer-components.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

js/viewer-components.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

js/viewer-filerobot.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

js/viewer-filerobot.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

js/viewer-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/viewer-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/viewer-plyr.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

js/viewer-plyr.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/Videos.vue

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- @copyright Copyright (c) 2019 John Molakvoæ <[email protected]>
33
-
44
- @author John Molakvoæ <[email protected]>
5+
- @author Richard Steinmetz <[email protected]>
56
-
67
- @license AGPL-3.0-or-later
78
-
@@ -53,21 +54,29 @@
5354
</template>
5455

5556
<script>
56-
import Vue from 'vue'
57-
import VuePlyr from '@skjnldsv/vue-plyr'
57+
// eslint-disable-next-line n/no-missing-import
5858
import '@skjnldsv/vue-plyr/dist/vue-plyr.css'
5959
import logger from '../services/logger.js'
6060
import { imagePath } from '@nextcloud/router'
6161
62+
const VuePlyr = () => import(/* webpackChunkName: 'plyr' */'@skjnldsv/vue-plyr')
63+
6264
const liveExt = ['jpg', 'jpeg', 'png']
6365
const liveExtRegex = new RegExp(`\\.(${liveExt.join('|')})$`, 'i')
6466
const blankVideo = imagePath('viewer', 'blank.mp4')
6567
66-
Vue.use(VuePlyr)
67-
6868
export default {
6969
name: 'Videos',
7070
71+
components: {
72+
VuePlyr,
73+
},
74+
data() {
75+
return {
76+
isFullscreenButtonVisible: false,
77+
}
78+
},
79+
7180
computed: {
7281
livePhoto() {
7382
return this.fileList.find(file => {
@@ -106,10 +115,15 @@ export default {
106115
}
107116
},
108117
},
118+
// for some reason the video controls don't get mounted to the dom until after the component (Videos) is mounted,
119+
// using the mounted() hook will leave us with an empty array
109120
110-
mounted() {
121+
updated() {
111122
// Prevent swiping to the next/previous item when scrubbing the timeline or changing volume
112123
[...this.$el.querySelectorAll('.plyr__controls__item')].forEach(control => {
124+
if (control.getAttribute('data-plyr') === 'fullscreen') {
125+
control.addEventListener('click', this.hideHeaderAndFooter)
126+
}
113127
if (!control?.addEventListener) {
114128
return
115129
}
@@ -127,6 +141,17 @@ export default {
127141
},
128142
129143
methods: {
144+
hideHeaderAndFooter(e) {
145+
// work arround to get the state of the fullscreen button, aria-selected attribute is not reliable
146+
this.isFullscreenButtonVisible = !this.isFullscreenButtonVisible
147+
if (this.isFullscreenButtonVisible) {
148+
document.body.querySelector('main').classList.add('viewer__hidden-fullscreen')
149+
document.body.querySelector('footer').classList.add('viewer__hidden-fullscreen')
150+
} else {
151+
document.body.querySelector('main').classList.remove('viewer__hidden-fullscreen')
152+
document.body.querySelector('footer').classList.remove('viewer__hidden-fullscreen')
153+
}
154+
},
130155
// Updates the dimensions of the modal
131156
updateVideoSize() {
132157
this.naturalHeight = this.$refs.video?.videoHeight
@@ -157,13 +182,13 @@ video {
157182
z-index: 20050;
158183
align-self: center;
159184
max-width: 100%;
160-
max-height: 100%;
185+
max-height: calc(100% - 65px) !important;
161186
background-color: black;
162187
163188
justify-self: center;
164189
}
165190
166-
::v-deep {
191+
:deep() {
167192
.plyr:-webkit-full-screen video {
168193
width: 100% !important;
169194
height: 100% !important;
@@ -185,11 +210,22 @@ video {
185210
186211
&:hover,
187212
&:focus {
188-
color: var(--color-primary-text);
213+
color: var(--color-primary-element-text);
189214
background-color: var(--color-primary-element);
190215
}
191216
}
192217
}
193218
}
219+
</style>
220+
221+
<style lang="scss">
222+
main.viewer__hidden-fullscreen {
223+
height: 100vh !important;
224+
width: 100vw !important;
225+
margin: 0 !important;
226+
}
194227
228+
footer.viewer__hidden-fullscreen {
229+
display: none !important;
230+
}
195231
</style>

0 commit comments

Comments
 (0)