Skip to content

Commit

Permalink
added working volume slider for AudioPlayer component; wip on volume …
Browse files Browse the repository at this point in the history
…tooltip
  • Loading branch information
michaelchadwick committed Jul 10, 2024
1 parent 7ae01fb commit c42892b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
7 changes: 4 additions & 3 deletions app/components/audio-player.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="audio-player{{if this.isPlaying ' is-playing'}}">
<h3>{{t "components.audioPlayer.head"}}</h3>

{{#if @shouldLoop}}
<audio loop {{play-when this.isPlaying}} data-test-audio-player>
<audio loop {{play-when this.isPlaying}} volume={{this.audioVolume}} data-test-audio-player>
<source src={{@srcURL}} />
<track kind="captions" />
{{t "errors.notSupported" description="<audio>"}}
Expand All @@ -14,7 +14,8 @@
{{t "errors.notSupported" description="<audio>"}}
</audio>
{{/if}}
{{! <input type="range" min="0" max="100" step="1" value="20" id="audio-volume" /> }}
<input type="range" min="0" max="100" step="1" value={{this.rangeVolume}} id="audio-volume" oninput={{this.setVolume}} />
{{!-- <div class="volume-tooltip">{{this.rangeVolume}}</div> --}}

{{#if (eq this.env "production")}}
<div class="audio-title">{{split @srcURL delimiter="/" index=5}}</div>
Expand Down
13 changes: 10 additions & 3 deletions app/components/audio-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import ENV from 'remember-stuff/config/environment';

export default class AudioPlayerComponent extends Component {
@tracked isPlaying = false;
@tracked volume = 20;
@tracked rangeVolume = 30;
@tracked env = ENV.environment;

maxVolume = 100;
decreaseVolume = null;

@action
volChange(volume) {
this.volume = volume;
setVolume(event) {
this.rangeVolume = parseInt(event.target.value, 10);
}

@action
Expand All @@ -22,4 +25,8 @@ export default class AudioPlayerComponent extends Component {
pause() {
this.isPlaying = false;
}

get audioVolume() {
return (this.rangeVolume / 100).toFixed(2);
}
}
26 changes: 26 additions & 0 deletions app/styles/components/audio-player.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@
background-color: lightpink;
}

.audio-player #audio-volume {
position: relative;
}

.audio-player #audio-volume + .volume-tooltip {
background-color: #ffffff;
border: 1px solid #000000;
border-radius: 5px;
color: #000000;
display: none;
font-size: 0.85rem;
height: 12px;
padding: 5px;
position: absolute;
top: 10px;
width: 16px;
}

// .audio-player #audio-volume + .volume-tooltip::before {
// position
// }

.audio-player #audio-volume:hover .volume-tooltip {
display: block;
}

.audio-player.is-playing #btn-audio-pause {
background-color: #fdfdfd;
}
Expand Down

0 comments on commit c42892b

Please sign in to comment.