Skip to content

Commit

Permalink
[playlists] Load all pictures for smoother transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
frankrousseau committed Dec 20, 2024
1 parent eadc09a commit a78d877
Show file tree
Hide file tree
Showing 4 changed files with 280 additions and 31 deletions.
39 changes: 35 additions & 4 deletions src/components/pages/playlists/PlaylistPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,20 @@
}"
v-show="isCurrentPreviewPicture && !isLoading"
>
<picture-viewer
<multi-picture-viewer
ref="picture-player"
:big="true"
:default-height="pictureDefaultHeight"
:full-screen="fullScreen"
:light="false"
:margin-bottom="0"
:panzoom="false"
:preview="currentPreview"
high-quality
:current-preview="{
...currentPreview,
position: currentPreviewIndex + 1
}"
:previews="picturePreviews"
high-qualiy
/>
</div>

Expand Down Expand Up @@ -959,10 +963,11 @@ import ColorPicker from '@/components/widgets/ColorPicker.vue'
import Combobox from '@/components/widgets/Combobox.vue'
import ComboboxStyled from '@/components/widgets/ComboboxStyled.vue'
import DeleteModal from '@/components/modals/DeleteModal.vue'
import MultiPictureViewer from '@/components/previews/MultiPictureViewer.vue'
import ObjectViewer from '@/components/previews/ObjectViewer.vue'
import PencilPicker from '@/components/widgets/PencilPicker.vue'
import PictureViewer from '@/components/previews/PictureViewer.vue'
import PlaylistedEntity from '@/components/pages/playlists/PlaylistedEntity.vue'
import PictureViewer from '@/components/previews/PictureViewer.vue'
import RawVideoPlayer from '@/components/pages/playlists/RawVideoPlayer.vue'
import PreviewRoom from '@/components/widgets/PreviewRoom.vue'
import SelectTaskTypeModal from '@/components/modals/SelectTaskTypeModal.vue'
Expand All @@ -988,6 +993,7 @@ export default {
ObjectViewer,
PencilPicker,
PictureViewer,
MultiPictureViewer,
PlayIcon,
PlaylistedEntity,
PreviewRoom,
Expand Down Expand Up @@ -1146,6 +1152,31 @@ export default {
return this.$refs['full-playlist-player']
},
picturePreviews() {
const picturePreviews = []
this.entityList.forEach(e => {
picturePreviews.push({
id: e.preview_file_id,
height: e.preview_file_height,
width: e.preview_file_width,
extension: e.preview_file_extension,
revision: e.preview_file_revision,
position: 1
})
e.preview_file_previews.forEach((p, index) => {
picturePreviews.push({
id: p.id,
height: p.height,
width: p.width,
extension: p.extension,
revision: p.revision,
position: index + 2
})
})
})
return picturePreviews
},
isMovieComparison() {
if (!this.currentPreviewToCompare) return false
return this.currentPreviewToCompare.extension === 'mp4'
Expand Down
12 changes: 10 additions & 2 deletions src/components/pages/playlists/RawVideoPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,16 @@ export default {
)
const rate = this.$options.rate || 1
this.currentPlayer.src = this.getMoviePath(entity)
this.nextPlayer.src = this.getMoviePath(nextEntity)
if (entity.preview_file_extension === 'mp4' && this.currentPlayer) {
this.currentPlayer.src = this.getMoviePath(entity)
} else if (this.currentPlayer) {
this.currentPlayer.src = ''
}
if (nextEntity.preview_file_extension === 'mp4' && this.nextPlayer) {
this.nextPlayer.src = this.getMoviePath(nextEntity)
} else if (this.nextPlayer) {
this.nextPlayer.src = ''
}
this.currentPlayer.style.display = 'block'
this.nextPlayer.style.display = 'none'
this.resetHeight()
Expand Down
219 changes: 219 additions & 0 deletions src/components/previews/MultiPictureViewer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
<template>
<div ref="container" class="multi-picture-player">
<picture-viewer
:ref="'picture-'+ preview.id + '-' + preview.position"
v-for="preview in previews"
v-show="
preview.id === currentPreview.id &&
preview.position === currentPreview.position
"
:key="preview.id"
:preview="preview"
:full-screen="fullScreen"
:high-quality="highQuality"
:is-comparing="isComparing"
:light="light"
:panzoom="panzoom"
:default-height="defaultHeight"
:margin-bottom="marginBottom"
/>
</div>
</template>

<script>
import { fullScreenMixin } from '@/components/mixins/fullscreen'
import { domMixin } from '@/components/mixins/dom'
import PictureViewer from '@/components/previews/PictureViewer'
export default {
name: 'multi-picture-viewer',
mixins: [domMixin, fullScreenMixin],
components: {
PictureViewer
},
props: {
big: {
type: Boolean,
default: false
},
defaultHeight: {
type: Number,
default: 0
},
marginBottom: {
type: Number,
default: 0
},
fullScreen: {
type: Boolean,
default: false
},
highQuality: {
type: Boolean,
default: false
},
isComparing: {
type: Boolean,
default: false
},
light: {
type: Boolean,
default: false
},
panzoom: {
type: Boolean,
default: false
},
currentPreview: {
type: Object,
default: () => null
},
previews: {
type: Array,
default: () => []
}
},
emits: ['loaded', 'size-changed'],
data() {
return {
}
},
mounted() {
this.container.style.height = this.defaultHeight + 'px'
},
beforeUnmount() {
},
computed: {
container() {
return this.$refs.container
}
},
methods: {
getDimensions() {
if (!this.currentPreview) return { height: 0, width: 0 }
const previewPlayer = this.$refs[
'picture-' + this.currentPreview.id + '-' + this.currentPreview.position
]
if (previewPlayer && previewPlayer[0]) {
return previewPlayer[0].getDimensions()
}
},
onWindowResize() {
this.resetPicture()
},
// Configuration
resetPicture() {
this.container.style.height = this.defaultHeight + 'px'
if (this.currentPreview) {
const key =
'picture-' + this.currentPreview.id + '-' + this.currentPreview.position
const previewPlayer = this.$refs[key]
if (previewPlayer && previewPlayer[0]) {
previewPlayer[0].resetPicture()
}
}
}
},
watch: {
fullScreen() {
this.resetPicture()
},
isComparing() {
setTimeout(() => {
this.resetPicture()
}, 20)
},
currentPreview() {
this.resetPicture()
},
previews() {
this.resetPicture()
}
}
}
</script>

<style lang="scss" scoped>
.loading-background {
width: 100%;
height: 100%;
background: black;
display: flex;
background: black;
align-items: center;
justify-content: center;
}
.multi-picture-player {
display: flex;
flex-direction: column;
align-content: flex-end;
border-radius: 5px;
height: 100%;
}
.spinner {
margin-top: 1em;
margin-bottom: 1em;
}
.picture-wrapper {
flex: 1;
border-radius: 5px;
display: flex;
background: black;
align-items: center;
justify-content: center;
text-align: center;
width: 100%;
z-index: 300;
margin: auto;
overflow: hidden;
}
.picture-subwrapper {
position: relative;
}
.multi-picture-player {
width: 100%;
text-align: center;
background: #36393f;
}
.loupe {
display: none;
position: absolute;
top: 0;
left: 0;
height: 300px;
width: 300px;
background: white;
z-index: 3000;
border-radius: 5px;
box-shadow: 0 0 8px 4px rgba(0, 0, 0, 0.2);
img {
position: relative;
width: 800px;
}
}
</style>
Loading

0 comments on commit a78d877

Please sign in to comment.