Skip to content

Commit

Permalink
fix(player): skip playback progress if not authed
Browse files Browse the repository at this point in the history
Fixes issues with non-authenticated users watching VODs and getting redirected to the login page when the playback progress request fails due to them not being logged in.
  • Loading branch information
Zibbp committed Sep 8, 2022
1 parent 35a9c40 commit e991aef
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions components/Vod/VideoPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
</template>

<script setup>
import { useAuthStore } from "~/stores/AuthStore";
const config = useRuntimeConfig().public;
const { $bus } = useNuxtApp();
const authStore = useAuthStore();
const props = defineProps({
vod: {
type: Object,
Expand Down Expand Up @@ -120,7 +123,7 @@ onMounted(async () => {
// Update video playback progress
// every 30 seconds
// only when playing
if (vodVideoPlayer.playing) {
if (vodVideoPlayer.playing && authStore.isAuthenticated) {
try {
const currentTime = parseInt(vodVideoPlayer.currentTime);
useApi(`/api/v1/playback/progress`, {
Expand All @@ -130,7 +133,7 @@ onMounted(async () => {
time: currentTime,
},
credentials: "include",
});
}, true);
} catch (error) {
console.error("Error sending playback progress:", error);
}
Expand All @@ -147,7 +150,7 @@ onMounted(async () => {
status: "finished",
},
credentials: "include",
});
}, true);
} catch (error) {
console.error("Error updating playback status");
console.error(error);
Expand Down

0 comments on commit e991aef

Please sign in to comment.