mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-30 18:43:17 +00:00
Implement autoplay of videos.
This commit is contained in:
parent
e9d1a77a6a
commit
e2f0892269
@ -1,3 +1,4 @@
|
||||
export default {
|
||||
BASE_URL: localStorage.getItem("instance") || 'https://pipedapi.kavin.rocks',
|
||||
AUTO_PLAY: localStorage.getItem("autoplay") || false
|
||||
}
|
||||
|
@ -33,6 +33,14 @@
|
||||
|
||||
<hr />
|
||||
|
||||
<b>Auto Play next Video:</b>
|
||||
<input
|
||||
class="uk-checkbox"
|
||||
v-model="selectedAutoPlay"
|
||||
@change="onChange($event)"
|
||||
type="checkbox"
|
||||
/>
|
||||
|
||||
<div
|
||||
class="uk-tile-default uk-text-secondary"
|
||||
style="background: #0b0e0f; width: 300px"
|
||||
@ -80,6 +88,7 @@ export default {
|
||||
mounted() {
|
||||
this.getVideoData();
|
||||
this.getSponsors();
|
||||
this.selectedAutoPlay = Constants.AUTO_PLAY;
|
||||
},
|
||||
beforeUnmount() {
|
||||
if (this.player) {
|
||||
@ -116,6 +125,10 @@ export default {
|
||||
)
|
||||
).json();
|
||||
},
|
||||
onChange() {
|
||||
if (localStorage)
|
||||
localStorage.setItem("autoplay", this.selectedAutoPlay);
|
||||
},
|
||||
async getVideoData() {
|
||||
this.fetchVideo()
|
||||
.then(data => (this.video = data))
|
||||
@ -246,6 +259,16 @@ export default {
|
||||
this.player.on("volumechange", () => {
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user