mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-25 06:57:22 +00:00
Merge pull request #2160 from vr10t/toast
Add countdown until next video
This commit is contained in:
commit
9eff395da6
@ -45,6 +45,16 @@
|
|||||||
@change="onChange($event)"
|
@change="onChange($event)"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="pref" for="chkAutoPlayNextCountdown">
|
||||||
|
<strong v-t="'actions.autoplay_next_countdown'" />
|
||||||
|
<input
|
||||||
|
id="chkAutoPlayNextCountdown"
|
||||||
|
v-model="autoPlayNextCountdown"
|
||||||
|
class="input w-24"
|
||||||
|
type="number"
|
||||||
|
@change="onChange($event)"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
<label class="pref" for="chkAudioOnly">
|
<label class="pref" for="chkAudioOnly">
|
||||||
<strong v-t="'actions.audio_only'" />
|
<strong v-t="'actions.audio_only'" />
|
||||||
<input id="chkAudioOnly" v-model="listen" class="checkbox" type="checkbox" @change="onChange($event)" />
|
<input id="chkAudioOnly" v-model="listen" class="checkbox" type="checkbox" @change="onChange($event)" />
|
||||||
@ -346,6 +356,7 @@ export default {
|
|||||||
minSegmentLength: 0,
|
minSegmentLength: 0,
|
||||||
selectedTheme: "dark",
|
selectedTheme: "dark",
|
||||||
autoPlayVideo: true,
|
autoPlayVideo: true,
|
||||||
|
autoPlayNextCountdown: 5,
|
||||||
listen: false,
|
listen: false,
|
||||||
resolutions: [144, 240, 360, 480, 720, 1080, 1440, 2160, 4320],
|
resolutions: [144, 240, 360, 480, 720, 1080, 1440, 2160, 4320],
|
||||||
defaultQuality: 0,
|
defaultQuality: 0,
|
||||||
@ -462,6 +473,7 @@ export default {
|
|||||||
this.minSegmentLength = Math.max(this.getPreferenceNumber("minSegmentLength", 0), 0);
|
this.minSegmentLength = Math.max(this.getPreferenceNumber("minSegmentLength", 0), 0);
|
||||||
this.selectedTheme = this.getPreferenceString("theme", "dark");
|
this.selectedTheme = this.getPreferenceString("theme", "dark");
|
||||||
this.autoPlayVideo = this.getPreferenceBoolean("playerAutoPlay", true);
|
this.autoPlayVideo = this.getPreferenceBoolean("playerAutoPlay", true);
|
||||||
|
this.autoPlayNextCountdown = this.getPreferenceNumber("autoPlayNextCountdown", 5);
|
||||||
this.listen = this.getPreferenceBoolean("listen", false);
|
this.listen = this.getPreferenceBoolean("listen", false);
|
||||||
this.defaultQuality = Number(localStorage.getItem("quality"));
|
this.defaultQuality = Number(localStorage.getItem("quality"));
|
||||||
this.bufferingGoal = Math.max(Number(localStorage.getItem("bufferGoal")), 10);
|
this.bufferingGoal = Math.max(Number(localStorage.getItem("bufferGoal")), 10);
|
||||||
@ -516,6 +528,7 @@ export default {
|
|||||||
localStorage.setItem("minSegmentLength", this.minSegmentLength);
|
localStorage.setItem("minSegmentLength", this.minSegmentLength);
|
||||||
localStorage.setItem("theme", this.selectedTheme);
|
localStorage.setItem("theme", this.selectedTheme);
|
||||||
localStorage.setItem("playerAutoPlay", this.autoPlayVideo);
|
localStorage.setItem("playerAutoPlay", this.autoPlayVideo);
|
||||||
|
localStorage.setItem("autoPlayNextCountdown", this.autoPlayNextCountdown);
|
||||||
localStorage.setItem("listen", this.listen);
|
localStorage.setItem("listen", this.listen);
|
||||||
localStorage.setItem("quality", this.defaultQuality);
|
localStorage.setItem("quality", this.defaultQuality);
|
||||||
localStorage.setItem("bufferGoal", this.bufferingGoal);
|
localStorage.setItem("bufferGoal", this.bufferingGoal);
|
||||||
|
28
src/components/ToastComponent.vue
Normal file
28
src/components/ToastComponent.vue
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<template>
|
||||||
|
<div class="toast">
|
||||||
|
<slot />
|
||||||
|
<button @click="dismiss" v-t="'actions.dismiss'" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
dismiss() {
|
||||||
|
this.$emit("dismissed");
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.toast {
|
||||||
|
@apply bg-white/80 text-black flex flex-col justify-center fixed top-12 right-12 p-4 min-w-max shadow rounded duration-200 z-9999;
|
||||||
|
}
|
||||||
|
.dark .toast {
|
||||||
|
@apply bg-dark-900/80 text-white;
|
||||||
|
}
|
||||||
|
.toast button {
|
||||||
|
@apply underline;
|
||||||
|
}
|
||||||
|
</style>
|
@ -39,14 +39,6 @@ export default {
|
|||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
playlist: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
index: {
|
|
||||||
type: Number,
|
|
||||||
default: -1,
|
|
||||||
},
|
|
||||||
sponsors: {
|
sponsors: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => {
|
||||||
@ -409,13 +401,7 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
videoEl.addEventListener("ended", () => {
|
videoEl.addEventListener("ended", () => {
|
||||||
if (
|
this.$emit("ended");
|
||||||
!this.selectedAutoLoop &&
|
|
||||||
this.selectedAutoPlay &&
|
|
||||||
(this.playlist?.relatedStreams?.length > 0 || this.video.relatedStreams.length > 0)
|
|
||||||
) {
|
|
||||||
this.navigateNext();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,31 +611,6 @@ export default {
|
|||||||
this.$refs.videoEl.currentTime = time;
|
this.$refs.videoEl.currentTime = time;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
navigateNext() {
|
|
||||||
const params = this.$route.query;
|
|
||||||
let url = this.playlist?.relatedStreams?.[this.index]?.url ?? this.video.relatedStreams[0].url;
|
|
||||||
const searchParams = new URLSearchParams();
|
|
||||||
for (var param in params)
|
|
||||||
switch (param) {
|
|
||||||
case "v":
|
|
||||||
case "t":
|
|
||||||
break;
|
|
||||||
case "index":
|
|
||||||
if (this.index < this.playlist.relatedStreams.length) searchParams.set("index", this.index + 1);
|
|
||||||
break;
|
|
||||||
case "list":
|
|
||||||
if (this.index < this.playlist.relatedStreams.length) searchParams.set("list", params.list);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
searchParams.set(param, params[param]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// save the fullscreen state
|
|
||||||
searchParams.set("fullscreen", this.$ui.getControls().isFullScreenEnabled());
|
|
||||||
const paramStr = searchParams.toString();
|
|
||||||
if (paramStr.length > 0) url += "&" + paramStr;
|
|
||||||
this.$router.push(url);
|
|
||||||
},
|
|
||||||
updateMarkers() {
|
updateMarkers() {
|
||||||
const markers = this.$refs.container.querySelector(".shaka-ad-markers");
|
const markers = this.$refs.container.querySelector(".shaka-ad-markers");
|
||||||
const array = ["to right"];
|
const array = ["to right"];
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
ref="videoPlayer"
|
ref="videoPlayer"
|
||||||
:video="video"
|
:video="video"
|
||||||
:sponsors="sponsors"
|
:sponsors="sponsors"
|
||||||
:playlist="playlist"
|
|
||||||
:index="index"
|
|
||||||
:selected-auto-play="false"
|
:selected-auto-play="false"
|
||||||
:selected-auto-loop="selectedAutoLoop"
|
:selected-auto-loop="selectedAutoLoop"
|
||||||
:is-embed="isEmbed"
|
:is-embed="isEmbed"
|
||||||
@ -14,6 +12,11 @@
|
|||||||
|
|
||||||
<LoadingIndicatorPage :show-content="video && !isEmbed" class="w-full">
|
<LoadingIndicatorPage :show-content="video && !isEmbed" class="w-full">
|
||||||
<ErrorHandler v-if="video && video.error" :message="video.message" :error="video.error" />
|
<ErrorHandler v-if="video && video.error" :message="video.message" :error="video.error" />
|
||||||
|
<Transition>
|
||||||
|
<ToastComponent v-if="shouldShowToast" @dismissed="dismiss">
|
||||||
|
<i18n-t keypath="info.next_video_countdown">{{ counter }}</i18n-t>
|
||||||
|
</ToastComponent>
|
||||||
|
</Transition>
|
||||||
|
|
||||||
<div v-show="!video.error">
|
<div v-show="!video.error">
|
||||||
<div :class="isMobile ? 'flex-col' : 'flex'">
|
<div :class="isMobile ? 'flex-col' : 'flex'">
|
||||||
@ -22,11 +25,10 @@
|
|||||||
ref="videoPlayer"
|
ref="videoPlayer"
|
||||||
:video="video"
|
:video="video"
|
||||||
:sponsors="sponsors"
|
:sponsors="sponsors"
|
||||||
:playlist="playlist"
|
|
||||||
:index="index"
|
|
||||||
:selected-auto-play="selectedAutoPlay"
|
:selected-auto-play="selectedAutoPlay"
|
||||||
:selected-auto-loop="selectedAutoLoop"
|
:selected-auto-loop="selectedAutoLoop"
|
||||||
@timeupdate="onTimeUpdate"
|
@timeupdate="onTimeUpdate"
|
||||||
|
@ended="onVideoEnded"
|
||||||
/>
|
/>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
<ChaptersBar
|
<ChaptersBar
|
||||||
@ -233,6 +235,7 @@ import ShareModal from "./ShareModal.vue";
|
|||||||
import PlaylistVideos from "./PlaylistVideos.vue";
|
import PlaylistVideos from "./PlaylistVideos.vue";
|
||||||
import WatchOnYouTubeButton from "./WatchOnYouTubeButton.vue";
|
import WatchOnYouTubeButton from "./WatchOnYouTubeButton.vue";
|
||||||
import LoadingIndicatorPage from "./LoadingIndicatorPage.vue";
|
import LoadingIndicatorPage from "./LoadingIndicatorPage.vue";
|
||||||
|
import ToastComponent from "./ToastComponent.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "App",
|
name: "App",
|
||||||
@ -247,6 +250,7 @@ export default {
|
|||||||
PlaylistVideos,
|
PlaylistVideos,
|
||||||
WatchOnYouTubeButton,
|
WatchOnYouTubeButton,
|
||||||
LoadingIndicatorPage,
|
LoadingIndicatorPage,
|
||||||
|
ToastComponent,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const smallViewQuery = window.matchMedia("(max-width: 640px)");
|
const smallViewQuery = window.matchMedia("(max-width: 640px)");
|
||||||
@ -272,6 +276,9 @@ export default {
|
|||||||
showShareModal: false,
|
showShareModal: false,
|
||||||
isMobile: true,
|
isMobile: true,
|
||||||
currentTime: 0,
|
currentTime: 0,
|
||||||
|
shouldShowToast: false,
|
||||||
|
timeoutCounter: null,
|
||||||
|
counter: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -293,6 +300,9 @@ export default {
|
|||||||
year: "numeric",
|
year: "numeric",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
defaultCounter(_this) {
|
||||||
|
return _this.getPreferenceNumber("autoPlayNextCountdown", 5);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
// check screen size
|
// check screen size
|
||||||
@ -362,10 +372,12 @@ export default {
|
|||||||
deactivated() {
|
deactivated() {
|
||||||
this.active = false;
|
this.active = false;
|
||||||
window.removeEventListener("scroll", this.handleScroll);
|
window.removeEventListener("scroll", this.handleScroll);
|
||||||
|
this.dismiss();
|
||||||
},
|
},
|
||||||
unmounted() {
|
unmounted() {
|
||||||
window.removeEventListener("scroll", this.handleScroll);
|
window.removeEventListener("scroll", this.handleScroll);
|
||||||
window.removeEventListener("click", this.handleClick);
|
window.removeEventListener("click", this.handleClick);
|
||||||
|
this.dismiss();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchVideo() {
|
fetchVideo() {
|
||||||
@ -562,6 +574,68 @@ export default {
|
|||||||
onTimeUpdate(time) {
|
onTimeUpdate(time) {
|
||||||
this.currentTime = time;
|
this.currentTime = time;
|
||||||
},
|
},
|
||||||
|
onVideoEnded() {
|
||||||
|
if (
|
||||||
|
!this.selectedAutoLoop &&
|
||||||
|
this.selectedAutoPlay &&
|
||||||
|
(this.playlist?.relatedStreams?.length > 0 || this.video.relatedStreams.length > 0)
|
||||||
|
) {
|
||||||
|
this.showToast();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
showToast() {
|
||||||
|
this.counter = this.defaultCounter;
|
||||||
|
if (this.counter < 1) {
|
||||||
|
this.navigateNext();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.timeoutCounter) clearInterval(this.timeoutCounter);
|
||||||
|
this.timeoutCounter = setInterval(() => {
|
||||||
|
this.counter--;
|
||||||
|
if (this.counter === 0) {
|
||||||
|
this.dismiss();
|
||||||
|
this.navigateNext();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
this.shouldShowToast = true;
|
||||||
|
},
|
||||||
|
dismiss() {
|
||||||
|
clearInterval(this.timeoutCounter);
|
||||||
|
this.shouldShowToast = false;
|
||||||
|
},
|
||||||
|
navigateNext() {
|
||||||
|
const params = this.$route.query;
|
||||||
|
let url = this.playlist?.relatedStreams?.[this.index]?.url ?? this.video.relatedStreams[0].url;
|
||||||
|
const searchParams = new URLSearchParams();
|
||||||
|
for (var param in params)
|
||||||
|
switch (param) {
|
||||||
|
case "v":
|
||||||
|
case "t":
|
||||||
|
break;
|
||||||
|
case "index":
|
||||||
|
if (this.index < this.playlist.relatedStreams.length) searchParams.set("index", this.index + 1);
|
||||||
|
break;
|
||||||
|
case "list":
|
||||||
|
if (this.index < this.playlist.relatedStreams.length) searchParams.set("list", params.list);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
searchParams.set(param, params[param]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// save the fullscreen state
|
||||||
|
searchParams.set("fullscreen", this.$refs.videoPlayer.$ui.getControls().isFullScreenEnabled());
|
||||||
|
const paramStr = searchParams.toString();
|
||||||
|
if (paramStr.length > 0) url += "&" + paramStr;
|
||||||
|
this.$router.push(url);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.v-enter-from,
|
||||||
|
.v-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateX(100%) scale(0.5);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
"dark": "Dark",
|
"dark": "Dark",
|
||||||
"light": "Light",
|
"light": "Light",
|
||||||
"autoplay_video": "Autoplay Video",
|
"autoplay_video": "Autoplay Video",
|
||||||
|
"autoplay_next_countdown": "Default Countdown until next video (in seconds)",
|
||||||
"audio_only": "Audio Only",
|
"audio_only": "Audio Only",
|
||||||
"default_quality": "Default Quality",
|
"default_quality": "Default Quality",
|
||||||
"buffering_goal": "Buffering Goal (in seconds)",
|
"buffering_goal": "Buffering Goal (in seconds)",
|
||||||
@ -128,6 +129,7 @@
|
|||||||
"with_playlist": "Share with playlist",
|
"with_playlist": "Share with playlist",
|
||||||
"bookmark_playlist": "Bookmark",
|
"bookmark_playlist": "Bookmark",
|
||||||
"playlist_bookmarked": "Bookmarked",
|
"playlist_bookmarked": "Bookmarked",
|
||||||
|
"dismiss": "Dismiss",
|
||||||
"show_more": "Show more",
|
"show_more": "Show more",
|
||||||
"show_less": "Show less"
|
"show_less": "Show less"
|
||||||
},
|
},
|
||||||
@ -182,6 +184,7 @@
|
|||||||
"copied": "Copied!",
|
"copied": "Copied!",
|
||||||
"cannot_copy": "Can't copy!",
|
"cannot_copy": "Can't copy!",
|
||||||
"local_storage": "This action requires localStorage, are cookies enabled?",
|
"local_storage": "This action requires localStorage, are cookies enabled?",
|
||||||
"register_no_email_note": "Using an e-mail as username is not recommended. Proceed anyways?"
|
"register_no_email_note": "Using an e-mail as username is not recommended. Proceed anyways?",
|
||||||
|
"next_video_countdown": "Playing next video in {0}s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user