feat: dynamic autoplay on previewer

pull/1353/head
Ramires Viana 2021-03-26 17:31:27 +00:00
parent 2697093ac1
commit a76e01d2b7
1 changed files with 25 additions and 2 deletions

View File

@ -57,8 +57,22 @@
<template v-if="!loading">
<div class="preview">
<ExtendedImage v-if="req.type == 'image'" :src="raw"></ExtendedImage>
<audio v-else-if="req.type == 'audio'" :src="raw" controls></audio>
<video v-else-if="req.type == 'video'" :src="raw" controls>
<audio
v-else-if="req.type == 'audio'"
ref="player"
:src="raw"
controls
:autoplay="autoPlay"
@play="autoPlay = true"
></audio>
<video
v-else-if="req.type == 'video'"
ref="player"
:src="raw"
controls
:autoplay="autoPlay"
@play="autoPlay = true"
>
<track
kind="captions"
v-for="(sub, index) in subtitles"
@ -139,6 +153,7 @@ export default {
showNav: true,
navTimeout: null,
hoverNav: false,
autoPlay: false,
};
},
computed: {
@ -233,6 +248,14 @@ export default {
}
},
async updatePreview() {
if (
this.$refs.player &&
this.$refs.player.paused &&
!this.$refs.player.ended
) {
this.autoPlay = false;
}
if (this.req.subtitles) {
this.subtitles = this.req.subtitles.map(
(sub) => `${baseURL}/api/raw${sub}?auth=${this.jwt}&inline=true`