Skip to content

Commit 362b05c

Browse files
authored
Merge pull request #3352 from nextcloud/backport/3350/stable35
[stable35] feat: Support auto-starting slideshow
2 parents faf9bc3 + 7b6437a commit 362b05c

11 files changed

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

css/viewer-init.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* extracted by css-entry-points-plugin */
2-
@import './init-Pfn7QR6a.chunk.css';
2+
@import './init-BD3WReu1.chunk.css';
33
@import './previewUtils-DsspQ6dL.chunk.css';
44
@import './NcIconSvgWrapper-Bui9PhAS-3xIBDiQU.chunk.css';
55
@import './NcActionButton-BjaRp7qa.chunk.css';

css/viewer-main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/* extracted by css-entry-points-plugin */
2-
@import './main-fKdjIrca.chunk.css';
2+
@import './main-C9ftJeUl.chunk.css';
33
@import './previewUtils-DsspQ6dL.chunk.css';

js/viewer-init.mjs

Lines changed: 25 additions & 25 deletions
Large diffs are not rendered by default.

js/viewer-init.mjs.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-main.mjs

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

js/viewer-main.mjs.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.

src/components/Videos.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
:src="url"
2121
preload="metadata"
2222
@error.capture.prevent.stop.once="onFail"
23+
@play="onPlay"
24+
@pause="onPause"
2325
@ended="donePlaying"
2426
@canplay="doneLoading"
2527
@loadedmetadata="onLoadedMetadata">
@@ -182,7 +184,17 @@ export default {
182184
this.updateHeightWidth()
183185
},
184186
187+
onPlay() {
188+
this.$emit('update:playing', true)
189+
},
190+
191+
onPause() {
192+
this.$emit('update:playing', false)
193+
},
194+
185195
donePlaying() {
196+
this.$emit('update:playing', false)
197+
186198
// reset and show poster after play
187199
this.$refs.video.autoplay = false
188200
this.$refs.video.load()

src/services/Viewer.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export default class Viewer {
5555
this._state.onNext = () => {}
5656
this._state.onClose = () => {}
5757
this._state.canLoop = true
58+
this._state.startSlideshow = false
5859
this._state.handlers = []
5960
this._state.overrideHandlerId = null
6061

@@ -258,6 +259,16 @@ export default class Viewer {
258259
return this._state.canLoop
259260
}
260261

262+
/**
263+
* Whether the slideshow start playing as soon as the viewer is opens
264+
*
265+
* @memberof Viewer
266+
* @return {boolean}
267+
*/
268+
get startSlideshow() {
269+
return this._state.startSlideshow
270+
}
271+
261272
/**
262273
* If this handler is set, it should be used for viewing the next file.
263274
*
@@ -291,11 +302,23 @@ export default class Viewer {
291302
* @param {boolean} options.enableSidebar whether to enable the sidebar or not
292303
* @param {Function} options.loadMore callback for loading more files
293304
* @param {boolean} options.canLoop can the viewer loop over the array
305+
* @param {boolean} options.startSlideshow start playing the slideshow right away
294306
* @param {Function} options.onPrev callback when navigating back to previous file
295307
* @param {Function} options.onNext callback when navigation forward to next file
296308
* @param {Function} options.onClose callback when closing the viewer
297309
*/
298-
open({ path, fileInfo, list = [], enableSidebar = true, loadMore = () => ([]), canLoop = true, onPrev = () => {}, onNext = () => {}, onClose = () => {} } = {}) {
310+
open({
311+
path,
312+
fileInfo,
313+
list = [],
314+
enableSidebar = true,
315+
loadMore = () => [],
316+
canLoop = true,
317+
startSlideshow = false,
318+
onPrev = () => {},
319+
onNext = () => {},
320+
onClose = () => {},
321+
} = {}) {
299322
if (typeof arguments[0] === 'string') {
300323
throw new Error('Opening the viewer with a single string parameter is deprecated. Please use a destructuring object instead', `OCA.Viewer.open({ path: '${path}' })`)
301324
}
@@ -330,6 +353,7 @@ export default class Viewer {
330353
this._state.onNext = onNext
331354
this._state.onClose = onClose
332355
this._state.canLoop = canLoop
356+
this._state.startSlideshow = startSlideshow
333357
}
334358
}
335359

@@ -378,6 +402,7 @@ export default class Viewer {
378402
this._state.files = []
379403
this._state.enableSidebar = true
380404
this._state.canLoop = true
405+
this._state.startSlideshow = false
381406
this._state.loadMore = () => ([])
382407
this._state.overrideHandlerId = null
383408
}

0 commit comments

Comments
 (0)