Skip to content

Commit

Permalink
Merge branch 'live-repeat' of https://github.com/jovanbulck/memories
Browse files Browse the repository at this point in the history
…into jovanbulck-live-repeat
  • Loading branch information
pulsejet committed Nov 16, 2024
2 parents b5b40c1 + e744c83 commit 4b358e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/frame/Photo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
<span class="time" v-if="data.video_duration">{{ videoDuration }}</span>
<VideoIcon :size="22" />
</div>
<div class="livephoto" v-if="data.liveid" @mouseenter.passive="playVideo" @mouseleave.passive="stopVideo">
<div
class="livephoto"
v-if="data.liveid"
@mouseenter.passive="playVideo"
@mouseleave.passive="stopVideo"
@touchstart.passive="touchVideo"
>
<LivePhotoIcon :size="22" :spin="liveState.waiting" :playing="liveState.playing" />
</div>
</div>
Expand Down Expand Up @@ -292,6 +298,7 @@ export default defineComponent({
try {
this.liveState.requested = true;
video.currentTime = 0;
video.loop = true;
await video.play();
} catch (e) {
// ignore, pause was probably called too soon
Expand All @@ -310,6 +317,12 @@ export default defineComponent({
this.liveState.playTimer = 0;
this.liveState.waiting = false;
},
/** Start/stop preview video for touchscreens */
touchVideo() {
if (this.liveState.playing) this.stopVideo();
else this.playVideo();
},
},
});
</script>
Expand Down
6 changes: 6 additions & 0 deletions src/components/viewer/PsLivePhoto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class LivePhotoContentSetup {
const video = content.element?.querySelector('video');
if (!video) return;

if (this.liveState.playing) {
video.pause();
return;
}

try {
this.liveState.waiting = true;
video.currentTime = 0;
Expand All @@ -57,6 +62,7 @@ class LivePhotoContentSetup {
video.playsInline = true;
video.disableRemotePlayback = true;
video.autoplay = false;
video.loop = true;
video.src = utils.getLivePhotoVideoUrl(photo, true);

const div = document.createElement('div');
Expand Down

0 comments on commit 4b358e8

Please sign in to comment.