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