|
|
|
@ -191,8 +191,9 @@ export class MediaProgressLine extends RangeSelector {
@@ -191,8 +191,9 @@ export class MediaProgressLine extends RangeSelector {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export class VolumeSelector extends RangeSelector { |
|
|
|
|
private static ICONS = ['volume_off', 'volume_mute', 'volume_down', 'volume_up']; |
|
|
|
|
public btn: HTMLElement; |
|
|
|
|
protected volumeSvg: HTMLElement; |
|
|
|
|
protected icon: HTMLSpanElement; |
|
|
|
|
|
|
|
|
|
constructor(protected listenerSetter: ListenerSetter, protected vertical = false) { |
|
|
|
|
super({ |
|
|
|
@ -218,18 +219,15 @@ export class VolumeSelector extends RangeSelector {
@@ -218,18 +219,15 @@ export class VolumeSelector extends RangeSelector {
|
|
|
|
|
} */ |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.btn = document.createElement('div'); |
|
|
|
|
this.btn.classList.add('player-volume'); |
|
|
|
|
const className = 'player-volume'; |
|
|
|
|
const btn = this.btn = document.createElement('div'); |
|
|
|
|
btn.classList.add('btn-icon', className); |
|
|
|
|
const icon = this.icon = document.createElement('span'); |
|
|
|
|
icon.classList.add(className + '__icon'); |
|
|
|
|
|
|
|
|
|
this.btn.innerHTML = ` |
|
|
|
|
<svg class="player-volume__icon" focusable="false" viewBox="0 0 24 24" aria-hidden="true"></svg> |
|
|
|
|
`;
|
|
|
|
|
this.btn.classList.add('btn-icon'); |
|
|
|
|
this.volumeSvg = this.btn.firstElementChild as HTMLElement; |
|
|
|
|
btn.append(icon, this.container); |
|
|
|
|
|
|
|
|
|
this.btn.append(this.container); |
|
|
|
|
|
|
|
|
|
attachClickEvent(this.volumeSvg, this.onMuteClick, {listenerSetter: this.listenerSetter}); |
|
|
|
|
attachClickEvent(icon, this.onMuteClick, {listenerSetter: this.listenerSetter}); |
|
|
|
|
this.listenerSetter.add(rootScope)('media_playback_params', this.setVolume); |
|
|
|
|
|
|
|
|
|
this.setVolume(); |
|
|
|
@ -244,19 +242,19 @@ export class VolumeSelector extends RangeSelector {
@@ -244,19 +242,19 @@ export class VolumeSelector extends RangeSelector {
|
|
|
|
|
// const volume = video.volume;
|
|
|
|
|
const {volume, muted} = appMediaPlaybackController; |
|
|
|
|
let d: string; |
|
|
|
|
let iconIndex: number; |
|
|
|
|
if(!volume || muted) { |
|
|
|
|
d = `M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z`; |
|
|
|
|
iconIndex = 0; |
|
|
|
|
} else if(volume > .5) { |
|
|
|
|
d = `M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z`; |
|
|
|
|
iconIndex = 3; |
|
|
|
|
} else if(volume > 0 && volume < .25) { |
|
|
|
|
d = `M7 9v6h4l5 5V4l-5 5H7z`; |
|
|
|
|
iconIndex = 1; |
|
|
|
|
} else { |
|
|
|
|
d = `M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z`; |
|
|
|
|
iconIndex = 2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
this.volumeSvg.innerHTML = `<path d="${d}"></path>`; |
|
|
|
|
} catch(err) {} |
|
|
|
|
VolumeSelector.ICONS.forEach(icon => this.icon.classList.remove('tgico-' + icon)); |
|
|
|
|
this.icon.classList.add('tgico-' + VolumeSelector.ICONS[iconIndex]); |
|
|
|
|
|
|
|
|
|
if(!this.mousedown) { |
|
|
|
|
this.setProgress(muted ? 0 : volume); |
|
|
|
|