Skip to content

Commit

Permalink
feat: auto-repeat live photos
Browse files Browse the repository at this point in the history
Fixes pulsejet#1267

Signed-off-by: Jo Van Bulck <jo.vanbulck@cs.kuleuven.be>
  • Loading branch information
jovanbulck committed Nov 16, 2024
1 parent f1e2669 commit e744c83
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 e744c83

Please sign in to comment.