mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Implement autoplay of videos.
This commit is contained in:
parent
e9d1a77a6a
commit
e2f0892269
2 changed files with 24 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
||||||
export default {
|
export default {
|
||||||
BASE_URL: localStorage.getItem("instance") || 'https://pipedapi.kavin.rocks',
|
BASE_URL: localStorage.getItem("instance") || 'https://pipedapi.kavin.rocks',
|
||||||
|
AUTO_PLAY: localStorage.getItem("autoplay") || false
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,14 @@
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
<b>Auto Play next Video:</b>
|
||||||
|
<input
|
||||||
|
class="uk-checkbox"
|
||||||
|
v-model="selectedAutoPlay"
|
||||||
|
@change="onChange($event)"
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="uk-tile-default uk-text-secondary"
|
class="uk-tile-default uk-text-secondary"
|
||||||
style="background: #0b0e0f; width: 300px"
|
style="background: #0b0e0f; width: 300px"
|
||||||
|
@ -80,6 +88,7 @@ export default {
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getVideoData();
|
this.getVideoData();
|
||||||
this.getSponsors();
|
this.getSponsors();
|
||||||
|
this.selectedAutoPlay = Constants.AUTO_PLAY;
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
if (this.player) {
|
if (this.player) {
|
||||||
|
@ -116,6 +125,10 @@ export default {
|
||||||
)
|
)
|
||||||
).json();
|
).json();
|
||||||
},
|
},
|
||||||
|
onChange() {
|
||||||
|
if (localStorage)
|
||||||
|
localStorage.setItem("autoplay", this.selectedAutoPlay);
|
||||||
|
},
|
||||||
async getVideoData() {
|
async getVideoData() {
|
||||||
this.fetchVideo()
|
this.fetchVideo()
|
||||||
.then(data => (this.video = data))
|
.then(data => (this.video = data))
|
||||||
|
@ -246,6 +259,16 @@ export default {
|
||||||
this.player.on("volumechange", () => {
|
this.player.on("volumechange", () => {
|
||||||
this.audioplayer.volume = this.player.volume();
|
this.audioplayer.volume = this.player.volume();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.player.on("ended", () => {
|
||||||
|
if (
|
||||||
|
this.selectedAutoPlay &&
|
||||||
|
this.video.relatedStreams.length > 0
|
||||||
|
)
|
||||||
|
this.$router.push(
|
||||||
|
this.video.relatedStreams[0].url
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!noPrevPlayer)
|
if (!noPrevPlayer)
|
||||||
|
|
Loading…
Reference in a new issue