<div class="ucap-sound-viewer-container">
  <mat-toolbar color="accent" class="ucap-sound-viewer-header">
    <mat-icon class="ucap-sound-viewer-icon">music_note</mat-icon>
    <span class="ucap-sound-viewer-title">{{ fileInfo.fileName }}</span>
    <span class="ucap-sound-viewer-spacer"></span>
    <button
      mat-icon-button
      class="ucap-sound-viewer-action"
      matTooltip="다운로드"
      matTooltipPosition="below"
      aria-label=""
      (click)="onClickDownload()"
    >
      <mat-icon>get_app</mat-icon>
    </button>
    <button
      mat-raised-button
      color="primary"
      class="ucap-sound-viewer-action"
      (click)="onClickClose()"
    >
      Close
    </button>
  </mat-toolbar>
  <mat-progress-bar
    *ngIf="fileDownloadItem && fileDownloadItem.downloadingProgress$"
    mode="determinate"
    [value]="fileDownloadItem.downloadingProgress$ | async"
  ></mat-progress-bar>
  <div class="ucap-sound-viewer-body">
    <div
      class="ucap-sound-viewer-sound-icon"
      fxLayout="row"
      fxLayout.xs="column"
      fxLayoutAlign="center center"
    >
      <audio
        [src]="fileDownloadUrl"
        #audioPlayer
        (playing)="onPlayingAudio()"
        (pause)="onPauseAudio()"
        (timeupdate)="onTimeUpdateAudio()"
        (volumechange)="onVolumeChangeAudio()"
        (loadstart)="onLoadStartAudio()"
        (loadeddata)="onLoadedDataAudio()"
      ></audio>
      <mat-icon class="ucap-sound-viewer-icon">music_note</mat-icon>
    </div>
    <div
      class="ucap-sound-viewer-sound-time"
      fxLayout="row"
      fxLayout.xs="column"
      fxLayoutAlign="center center"
    >
      <mat-slider
        #timeSlider
        min="0"
        [max]="duration"
        [value]="currentTime"
        (change)="onChangeTimeSlider($event)"
      >
      </mat-slider>
    </div>
    <div
      class="ucap-sound-viewer-sound-controls"
      fxLayout="row"
      fxLayout.xs="column"
      fxLayoutAlign="center center"
    >
      <div class="ucap-sound-viewer-sound-time-current">
        {{ currentTime | ucapSecondsToMinutes }}
      </div>
      <span class="ucap-sound-viewer-spacer"></span>
      <button
        mat-icon-button
        class="ucap-sound-viewer-action"
        [matTooltip]="playing ? '멈춤' : '재생'"
        aria-label=""
        (click)="onClickPlayOrPause()"
      >
        <mat-icon>{{ playing ? 'pause' : 'play_arrow' }}</mat-icon>
      </button>
      <span class="ucap-sound-viewer-spacer"></span>
      <div class="ucap-sound-viewer-sound-time-total">
        {{ duration | ucapSecondsToMinutes }}
      </div>
    </div>
  </div>
</div>
