Skip to content

Commit

Permalink
Autoplay only on app start
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan committed Nov 28, 2022
1 parent 46b44ca commit c2bde9b
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/web-app-preview/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
:key="`media-video-${activeMediaFileCached.id}`"
controls
preload
autoplay
:autoplay="isAutoPlayEnabled"
>
<source :src="activeMediaFileCached.url" :type="activeMediaFileCached.mimeType" />
</video>
Expand All @@ -59,7 +59,7 @@
:key="`media-audio-${activeMediaFileCached.id}`"
controls
preload
autoplay
:autoplay="isAutoPlayEnabled"
>
<source :src="activeMediaFileCached.url" :type="activeMediaFileCached.mimeType" />
</audio>
Expand Down Expand Up @@ -96,7 +96,7 @@
</main>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { defineComponent, unref } from 'vue'
import { mapGetters } from 'vuex'
import {
useAccessToken,
Expand All @@ -108,7 +108,6 @@ import Preview from './index'
import AppTopBar from 'web-pkg/src/components/AppTopBar.vue'
import { loadPreview } from 'web-pkg/src/helpers'
import { configurationManager } from 'web-pkg/src/configuration'
import { unref } from 'vue'
import { createFileRouteOptions, mergeFileRouteOptions } from 'web-pkg/src/helpers/router'
export default defineComponent({
Expand All @@ -135,7 +134,9 @@ export default defineComponent({
activeIndex: null,
direction: 'rtl',
cachedFiles: []
cachedFiles: [],
isAutoPlayEnabled: true
}
},
Expand Down Expand Up @@ -207,10 +208,14 @@ export default defineComponent({
},
watch: {
activeIndex(o, n) {
if (o !== n) {
activeIndex(newValue, oldValue) {
if (newValue !== oldValue) {
this.loadMedium()
}
if (oldValue !== null) {
this.isAutoPlayEnabled = false
}
}
},
Expand Down

0 comments on commit c2bde9b

Please sign in to comment.