mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	Implement default quality preference.
This commit is contained in:
		
							parent
							
								
									8bf660c6c5
								
							
						
					
					
						commit
						0094ef9f15
					
				
					 2 changed files with 44 additions and 1 deletions
				
			
		| 
						 | 
					@ -1,7 +1,12 @@
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
    <div class="uk-container-expand">
 | 
					    <div class="uk-container-expand">
 | 
				
			||||||
        <div data-shaka-player-container ref="container">
 | 
					        <div data-shaka-player-container ref="container">
 | 
				
			||||||
            <video data-shaka-player :autoplay="shouldAutoPlay" style="width: 100%; height: 100%; max-height: 75vh; min-height: 250px;" ref="videoEl"></video>
 | 
					            <video
 | 
				
			||||||
 | 
					                data-shaka-player
 | 
				
			||||||
 | 
					                :autoplay="shouldAutoPlay"
 | 
				
			||||||
 | 
					                style="width: 100%; height: 100%; max-height: 75vh; min-height: 250px;"
 | 
				
			||||||
 | 
					                ref="videoEl"
 | 
				
			||||||
 | 
					            ></video>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
| 
						 | 
					@ -134,7 +139,27 @@ export default {
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
                this.player.configure("manifest.disableVideo", true);
 | 
					                this.player.configure("manifest.disableVideo", true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            const quality = Number(localStorage.getItem("quality"));
 | 
				
			||||||
 | 
					            const qualityConds = quality > 0 && (this.video.audioStreams.length > 0 || this.video.livestream);
 | 
				
			||||||
 | 
					            if (qualityConds) this.player.configure("abr.enabled", false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            player.load(uri, 0, uri.indexOf("dash+xml") >= 0 ? "application/dash+xml" : "video/mp4").then(() => {
 | 
					            player.load(uri, 0, uri.indexOf("dash+xml") >= 0 ? "application/dash+xml" : "video/mp4").then(() => {
 | 
				
			||||||
 | 
					                if (qualityConds) {
 | 
				
			||||||
 | 
					                    var leastDiff = Number.MAX_VALUE;
 | 
				
			||||||
 | 
					                    var bestStream = null;
 | 
				
			||||||
 | 
					                    player
 | 
				
			||||||
 | 
					                        .getVariantTracks()
 | 
				
			||||||
 | 
					                        .sort((a, b) => a.bandwidth - b.bandwidth)
 | 
				
			||||||
 | 
					                        .forEach(stream => {
 | 
				
			||||||
 | 
					                            const diff = Math.abs(quality - stream.height);
 | 
				
			||||||
 | 
					                            if (diff < leastDiff) {
 | 
				
			||||||
 | 
					                                leastDiff = diff;
 | 
				
			||||||
 | 
					                                bestStream = stream;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					                    player.selectVariantTrack(bestStream);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                this.video.subtitles.map(subtitle => {
 | 
					                this.video.subtitles.map(subtitle => {
 | 
				
			||||||
                    player.addTextTrackAsync(
 | 
					                    player.addTextTrackAsync(
 | 
				
			||||||
                        subtitle.url,
 | 
					                        subtitle.url,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,6 +38,21 @@
 | 
				
			||||||
    <b>Audio Only</b>
 | 
					    <b>Audio Only</b>
 | 
				
			||||||
    <br />
 | 
					    <br />
 | 
				
			||||||
    <input class="uk-checkbox" v-model="audioOnly" @change="onChange($event)" type="checkbox" />
 | 
					    <input class="uk-checkbox" v-model="audioOnly" @change="onChange($event)" type="checkbox" />
 | 
				
			||||||
 | 
					    <br />
 | 
				
			||||||
 | 
					    <b>Default Quality</b>
 | 
				
			||||||
 | 
					    <br />
 | 
				
			||||||
 | 
					    <select class="uk-select" v-model="defaultQuality" @change="onChange($event)">
 | 
				
			||||||
 | 
					        <option value="0">Disable</option>
 | 
				
			||||||
 | 
					        <option>144</option>
 | 
				
			||||||
 | 
					        <option>240</option>
 | 
				
			||||||
 | 
					        <option>360</option>
 | 
				
			||||||
 | 
					        <option>480</option>
 | 
				
			||||||
 | 
					        <option>720</option>
 | 
				
			||||||
 | 
					        <option>1080</option>
 | 
				
			||||||
 | 
					        <option>1440</option>
 | 
				
			||||||
 | 
					        <option>2160</option>
 | 
				
			||||||
 | 
					        <option>4320</option>
 | 
				
			||||||
 | 
					    </select>
 | 
				
			||||||
    <h2>Instances List</h2>
 | 
					    <h2>Instances List</h2>
 | 
				
			||||||
    <table class="uk-table">
 | 
					    <table class="uk-table">
 | 
				
			||||||
        <thead>
 | 
					        <thead>
 | 
				
			||||||
| 
						 | 
					@ -85,6 +100,7 @@ export default {
 | 
				
			||||||
            skipMusicOffTopic: true,
 | 
					            skipMusicOffTopic: true,
 | 
				
			||||||
            autoPlayVideo: true,
 | 
					            autoPlayVideo: true,
 | 
				
			||||||
            audioOnly: false,
 | 
					            audioOnly: false,
 | 
				
			||||||
 | 
					            defaultQuality: 0,
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    mounted() {
 | 
					    mounted() {
 | 
				
			||||||
| 
						 | 
					@ -147,6 +163,7 @@ export default {
 | 
				
			||||||
            this.autoPlayVideo =
 | 
					            this.autoPlayVideo =
 | 
				
			||||||
                localStorage.getItem("playerAutoPlay") === null || localStorage.getItem("playerAutoPlay") === "true";
 | 
					                localStorage.getItem("playerAutoPlay") === null || localStorage.getItem("playerAutoPlay") === "true";
 | 
				
			||||||
            this.audioOnly = localStorage.getItem("audioOnly") === "true";
 | 
					            this.audioOnly = localStorage.getItem("audioOnly") === "true";
 | 
				
			||||||
 | 
					            this.defaultQuality = Number(localStorage.getItem("quality"));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    methods: {
 | 
					    methods: {
 | 
				
			||||||
| 
						 | 
					@ -166,6 +183,7 @@ export default {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                localStorage.setItem("playerAutoPlay", this.autoPlayVideo);
 | 
					                localStorage.setItem("playerAutoPlay", this.autoPlayVideo);
 | 
				
			||||||
                localStorage.setItem("audioOnly", this.audioOnly);
 | 
					                localStorage.setItem("audioOnly", this.audioOnly);
 | 
				
			||||||
 | 
					                localStorage.setItem("quality", this.defaultQuality);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        sslScore(url) {
 | 
					        sslScore(url) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue