this.selectAppropriateResolution(true)
}
- updateResolution (resolutionId: number, delay = 0) {
+ updateEngineResolution (resolutionId: number, delay = 0) {
// Remember player state
const currentTime = this.player.currentTime()
const isPaused = this.player.paused()
return this.currentVideoFile
}
+ changeQuality (id: number) {
+ if (id === -1) {
+ if (this.autoResolutionPossible === true) {
+ this.autoResolution = true
+
+ this.selectAppropriateResolution(false)
+ }
+
+ return
+ }
+
+ this.autoResolution = false
+ this.updateEngineResolution(id)
+ this.selectAppropriateResolution(false)
+ }
+
private addTorrent (
magnetOrTorrentUrl: string,
previousVideoFile: VideoFile,
}
if (changeResolution === true) {
- this.updateResolution(file.resolution.id, changeResolutionDelay)
+ this.updateEngineResolution(file.resolution.id, changeResolutionDelay)
// Wait some seconds in observation of our new resolution
this.isAutoResolutionObservation = true
label: this.buildQualityLabel(file),
height: file.resolution.id,
selected: false,
- selectCallback: () => this.qualitySwitchCallback(file.resolution.id)
+ selectCallback: () => this.changeQuality(file.resolution.id)
}))
resolutions.push({
id: -1,
label: this.player.localize('Auto'),
selected: true,
- selectCallback: () => this.qualitySwitchCallback(-1)
+ selectCallback: () => this.changeQuality(-1)
})
this.player.peertubeResolutions().add(resolutions)
return label
}
- private qualitySwitchCallback (id: number) {
- if (id === -1) {
- if (this.autoResolutionPossible === true) {
- this.autoResolution = true
-
- this.selectAppropriateResolution(false)
- }
-
- return
- }
-
- this.autoResolution = false
- this.updateResolution(id)
- this.selectAppropriateResolution(false)
- }
-
private selectAppropriateResolution (byEngine: boolean) {
const resolution = this.autoResolution
? -1
if (this.isWebtorrent()) {
if (resolutionId === -1 && this.embed.player.webtorrent().isAutoResolutionPossible() === false) return
- // Auto resolution
- if (resolutionId === -1) {
- this.embed.player.webtorrent().enableAutoResolution()
- return
- }
-
- this.embed.player.webtorrent().disableAutoResolution()
- this.embed.player.webtorrent().updateResolution(resolutionId)
+ this.embed.player.webtorrent().changeQuality(resolutionId)
return
}
- this.embed.player.p2pMediaLoader().getHLSJS().nextLevel = resolutionId
+ this.embed.player.p2pMediaLoader().getHLSJS().currentLevel = resolutionId
}
private getCaptions (): PeerTubeTextTrack[] {
this.embed.player.peertubeResolutions().on('resolutionsAdded', () => this.loadResolutions())
this.embed.player.peertubeResolutions().on('resolutionChanged', () => this.loadResolutions())
+ this.loadResolutions()
+
this.embed.player.on('volumechange', () => {
this.channel.notify({
method: 'volumeChange',
})
}
- private loadWebTorrentResolutions () {
- this.resolutions = []
-
- const currentResolutionId = this.embed.player.webtorrent().getCurrentResolutionId()
-
- for (const videoFile of this.embed.player.webtorrent().videoFiles) {
- let label = videoFile.resolution.label
- if (videoFile.fps && videoFile.fps >= 50) {
- label += videoFile.fps
- }
-
- this.resolutions.push({
- id: videoFile.resolution.id,
- label,
- src: videoFile.magnetUri,
- active: videoFile.resolution.id === currentResolutionId,
- height: videoFile.resolution.id
- })
- }
-
- this.channel.notify({
- method: 'resolutionUpdate',
- params: this.resolutions
- })
- }
-
private loadResolutions () {
this.resolutions = this.embed.player.peertubeResolutions().getResolutions()
.map(r => ({
id: r.id,
- label: r.height + 'p',
+ label: r.label,
active: r.selected,
width: r.width,
height: r.height