Implement autoplay of videos.

This commit is contained in:
FireMasterK 2020-12-10 13:23:30 +05:30
parent e9d1a77a6a
commit e2f0892269
No known key found for this signature in database
GPG Key ID: 8DFF5DD33E93DB58
2 changed files with 24 additions and 0 deletions

View File

@ -1,3 +1,4 @@
export default {
BASE_URL: localStorage.getItem("instance") || 'https://pipedapi.kavin.rocks',
AUTO_PLAY: localStorage.getItem("autoplay") || false
}

View File

@ -33,6 +33,14 @@
<hr />
<b>Auto Play next Video:</b>&nbsp;
<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)