탐색

v2.1.0
미디어

트랜스크립트

녹음이나 영상의 발화 내용을 재생 위치에 맞춰 큐로 보여 줍니다.

이 페이지의 내용

트랜스크립트는 녹음이나 영상의 발화 내용을 시작 시간이 표시된 큐 목록으로 보여 줍니다. 현재 재생 위치에 맞춰 표시가 바뀝니다. 현재 큐는 입체감 있는 배경 위에 진한 글자색으로 표시되고, 이전 큐에는 옅은 글자색이, 이후 큐에는 기본 본문 글자색이 적용됩니다. 큐를 선택하면 해당 위치부터 재생됩니다. transcript 동작은 aria-controls에 id로 지정한 미디어 플레이어나 일반 <audio>, <video>에 트랜스크립트를 연결합니다.

트랜스크립트

<div class="grid gap-sm max-w(480) mx-auto">  <div class="player" id="talk" role="group" aria-label="A short recording">    <audio class="player-media" src="/demo/recording.m4a" controls preload="metadata"></audio>    <div class="player-controls">      <button type="button" class="player-button player-play" aria-label="Play" aria-pressed="false">        <svg class="icon player-off" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <path d="M7.633 4.7883L14.865 8.9606A1.2 1.2 0 0 1 14.865 11.0394L7.633 15.2117A1.2 1.2 0 0 1 5.8333 14.1723L5.8333 5.8277A1.2 1.2 0 0 1 7.633 4.7883Z" />        </svg>        <svg class="icon player-on" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <rect x="5" y="3.75" width="3.3333" height="12.5" rx="0.8" /><rect x="11.6667" y="3.75" width="3.3333" height="12.5" rx="0.8" />        </svg>      </button>      <span class="player-elapsed">0:00</span>      <input type="range" class="slider player-seek" min="0" max="0" step="any" value="0" aria-label="Seek">      <span class="player-duration">0:00</span>    </div>  </div>  <section class="transcript" aria-label="Transcript" aria-controls="talk" style="--transcript-height: 12rem">    <ol class="transcript-list scroll-area">      <li class="transcript-cue" data-start="0.3">        <button type="button" class="transcript-time">0:00</button>        <p class="transcript-text">          This is a short recording, made to show the player and its transcript.        </p>      </li>      <li class="transcript-cue" data-start="4.7">        <button type="button" class="transcript-time">0:04</button>        <p class="transcript-text">          Each line of the transcript is a cue, with the time it begins.        </p>      </li>      <li class="transcript-cue" data-start="8.7">        <button type="button" class="transcript-time">0:08</button>        <p class="transcript-text">          The line being spoken is marked, and the transcript keeps it in view.        </p>      </li>      <li class="transcript-cue" data-start="13.06">        <button type="button" class="transcript-time">0:13</button>        <p class="transcript-text">          Lines you have heard turn quiet. The ones still to come wait in plain ink.        </p>      </li>      <li class="transcript-cue" data-start="17.65">        <button type="button" class="transcript-time">0:17</button>        <p class="transcript-text">          Choose any line to jump to it, or scroll away and come back later.        </p>      </li>      <li class="transcript-cue" data-start="21.79">        <button type="button" class="transcript-time">0:21</button>        <p class="transcript-text">That is the whole recording. Thank you for listening.</p>      </li>    </ol>    <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>      Back to current    </button>  </section></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'import PlayIcon from '@master/icons-react/native/20/soft/play'import PauseIcon from '@master/icons-react/native/20/soft/pause'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="grid gap-sm max-w(480) mx-auto">      <div className="player" id="talk" role="group" aria-label="A short recording">        <audio className="player-media" src="/demo/recording.m4a" controls preload="metadata"></audio>        <div className="player-controls">          <button type="button" className="player-button player-play" aria-label="Play" aria-pressed="false">            <PlayIcon className="icon player-off" />            <PauseIcon className="icon player-on" />          </button>          <span className="player-elapsed">0:00</span>          <input type="range" className="slider player-seek" min="0" max="0" step="any" defaultValue="0" aria-label="Seek" />          <span className="player-duration">0:00</span>        </div>      </div>      <section className="transcript" aria-label="Transcript" aria-controls="talk" style={{ '--transcript-height': '12rem' } as React.CSSProperties}>        <ol className="transcript-list scroll-area">          <li className="transcript-cue" data-start="0.3">            <button type="button" className="transcript-time">0:00</button>            <p className="transcript-text">              This is a short recording, made to show the player and its transcript.            </p>          </li>          <li className="transcript-cue" data-start="4.7">            <button type="button" className="transcript-time">0:04</button>            <p className="transcript-text">              Each line of the transcript is a cue, with the time it begins.            </p>          </li>          <li className="transcript-cue" data-start="8.7">            <button type="button" className="transcript-time">0:08</button>            <p className="transcript-text">              The line being spoken is marked, and the transcript keeps it in view.            </p>          </li>          <li className="transcript-cue" data-start="13.06">            <button type="button" className="transcript-time">0:13</button>            <p className="transcript-text">              Lines you have heard turn quiet. The ones still to come wait in plain ink.            </p>          </li>          <li className="transcript-cue" data-start="17.65">            <button type="button" className="transcript-time">0:17</button>            <p className="transcript-text">              Choose any line to jump to it, or scroll away and come back later.            </p>          </li>          <li className="transcript-cue" data-start="21.79">            <button type="button" className="transcript-time">0:21</button>            <p className="transcript-text">That is the whole recording. Thank you for listening.</p>          </li>        </ol>        <button type="button" className="btn btn-sm btn-pill transcript-return" hidden>          Back to current        </button>      </section>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'  import PlayIcon from '@master/icons-svelte/native/20/soft/play'  import PauseIcon from '@master/icons-svelte/native/20/soft/pause'</script><div class="grid gap-sm max-w(480) mx-auto" {@attach attach}>  <div class="player" id="talk" role="group" aria-label="A short recording">    <audio class="player-media" src="/demo/recording.m4a" controls preload="metadata"></audio>    <div class="player-controls">      <button type="button" class="player-button player-play" aria-label="Play" aria-pressed="false">        <PlayIcon class="icon player-off" />        <PauseIcon class="icon player-on" />      </button>      <span class="player-elapsed">0:00</span>      <input type="range" class="slider player-seek" min="0" max="0" step="any" value="0" aria-label="Seek">      <span class="player-duration">0:00</span>    </div>  </div>  <section class="transcript" aria-label="Transcript" aria-controls="talk" style="--transcript-height: 12rem">    <ol class="transcript-list scroll-area">      <li class="transcript-cue" data-start="0.3">        <button type="button" class="transcript-time">0:00</button>        <p class="transcript-text">          This is a short recording, made to show the player and its transcript.        </p>      </li>      <li class="transcript-cue" data-start="4.7">        <button type="button" class="transcript-time">0:04</button>        <p class="transcript-text">          Each line of the transcript is a cue, with the time it begins.        </p>      </li>      <li class="transcript-cue" data-start="8.7">        <button type="button" class="transcript-time">0:08</button>        <p class="transcript-text">          The line being spoken is marked, and the transcript keeps it in view.        </p>      </li>      <li class="transcript-cue" data-start="13.06">        <button type="button" class="transcript-time">0:13</button>        <p class="transcript-text">          Lines you have heard turn quiet. The ones still to come wait in plain ink.        </p>      </li>      <li class="transcript-cue" data-start="17.65">        <button type="button" class="transcript-time">0:17</button>        <p class="transcript-text">          Choose any line to jump to it, or scroll away and come back later.        </p>      </li>      <li class="transcript-cue" data-start="21.79">        <button type="button" class="transcript-time">0:21</button>        <p class="transcript-text">That is the whole recording. Thank you for listening.</p>      </li>    </ol>    <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>      Back to current    </button>  </section></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'import PlayIcon from '@master/icons-vue/native/20/soft/play'import PauseIcon from '@master/icons-vue/native/20/soft/pause'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="grid gap-sm max-w(480) mx-auto">    <div class="player" id="talk" role="group" aria-label="A short recording">      <audio class="player-media" src="/demo/recording.m4a" controls preload="metadata"></audio>      <div class="player-controls">        <button type="button" class="player-button player-play" aria-label="Play" aria-pressed="false">          <PlayIcon class="icon player-off" />          <PauseIcon class="icon player-on" />        </button>        <span class="player-elapsed">0:00</span>        <input type="range" class="slider player-seek" min="0" max="0" step="any" value="0" aria-label="Seek">        <span class="player-duration">0:00</span>      </div>    </div>    <section class="transcript" aria-label="Transcript" aria-controls="talk" style="--transcript-height: 12rem">      <ol class="transcript-list scroll-area">        <li class="transcript-cue" data-start="0.3">          <button type="button" class="transcript-time">0:00</button>          <p class="transcript-text">            This is a short recording, made to show the player and its transcript.          </p>        </li>        <li class="transcript-cue" data-start="4.7">          <button type="button" class="transcript-time">0:04</button>          <p class="transcript-text">            Each line of the transcript is a cue, with the time it begins.          </p>        </li>        <li class="transcript-cue" data-start="8.7">          <button type="button" class="transcript-time">0:08</button>          <p class="transcript-text">            The line being spoken is marked, and the transcript keeps it in view.          </p>        </li>        <li class="transcript-cue" data-start="13.06">          <button type="button" class="transcript-time">0:13</button>          <p class="transcript-text">            Lines you have heard turn quiet. The ones still to come wait in plain ink.          </p>        </li>        <li class="transcript-cue" data-start="17.65">          <button type="button" class="transcript-time">0:17</button>          <p class="transcript-text">            Choose any line to jump to it, or scroll away and come back later.          </p>        </li>        <li class="transcript-cue" data-start="21.79">          <button type="button" class="transcript-time">0:21</button>          <p class="transcript-text">That is the whole recording. Thank you for listening.</p>        </li>      </ol>      <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>        Back to current      </button>    </section>  </div></template>
재생한 뒤 줄을 하나 골라 보세요. 재생 중에 현재 줄이 화면에서 벗어나도록 트랜스크립트를 스크롤하면 자동 스크롤이 멈추고 현재 줄로 돌아가는 버튼이 나타납니다.

#자동 스크롤

미디어가 재생되는 동안 동작은 현재 큐에 aria-current="true"를 설정합니다. 현재 큐는 data-start가 지난 마지막 큐이므로, 두 큐 사이의 말 없는 구간에서도 위치가 유지됩니다. 그 앞의 모든 큐는 스타일시트만으로 재생된 상태로 그려집니다.

목록은 현재 큐를 가운데에 유지합니다. 자동 스크롤은 목록 안에서만 이루어지므로 페이지의 스크롤 위치는 그대로 유지됩니다. 목록은 부드럽게 스크롤되며, 사용자가 동작 줄이기를 설정한 경우에는 해당 위치로 즉시 이동합니다. 사용자가 휠, 손가락, 키, 스크롤바로 목록을 스크롤해 현재 큐가 보이지 않게 되면 목록은 따라가기를 멈추고, 아래 가장자리에 작은 알약 모양의 transcript-return이 나타나 다시 돌아가게 해 줍니다. 큐를 고르거나 현재 큐가 다시 보이도록 스크롤하면 다시 따라갑니다.

목록은 --transcript-height로 정한 높이 안에서 스크롤됩니다. 기본값은 20rem입니다. 얇은 스크롤바와 내용이 이어지는 가장자리의 페이드 효과가 필요하면 목록에 scroll-area를 추가하세요.

#WebVTT 트랙에서 가져오기

목록이 비어 있으면 동작은 TextTrack API로 미디어의 첫 번째 captions 또는 subtitles 트랙을 읽어 큐를 작성합니다. 시간, 태그를 제외한 문구, 그리고 음성 태그(<v Ana>)가 지정하는 화자를 작성합니다. 트랙은 비활성화 상태가 아닐 때만 큐를 불러오므로, 동작은 비활성화된 트랙을 hidden으로 설정합니다. hidden 트랙은 영상 위에 아무것도 표시하지 않습니다. 이 예시에서는 트랜스크립트가 브라우저 자체의 컨트롤이 있는 일반 <audio>를 따라갑니다.

트랙에서 가져오기

<div class="grid gap-sm max-w(480) mx-auto">  <audio id="talk-audio" class="w-full" src="/demo/recording.m4a" controls preload="metadata">    <track kind="captions" src="/demo/recording.vtt" srclang="en" label="English">  </audio>  <section class="transcript" aria-label="Transcript" aria-controls="talk-audio" style="--transcript-height: 15rem">    <ol class="transcript-list scroll-area"></ol>    <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>      Back to current    </button>  </section></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="grid gap-sm max-w(480) mx-auto">      <audio id="talk-audio" className="w-full" src="/demo/recording.m4a" controls preload="metadata">        <track kind="captions" src="/demo/recording.vtt" srcLang="en" label="English" />      </audio>      <section className="transcript" aria-label="Transcript" aria-controls="talk-audio" style={{ '--transcript-height': '15rem' } as React.CSSProperties}>        <ol className="transcript-list scroll-area"></ol>        <button type="button" className="btn btn-sm btn-pill transcript-return" hidden>          Back to current        </button>      </section>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'</script><div class="grid gap-sm max-w(480) mx-auto" {@attach attach}>  <audio id="talk-audio" class="w-full" src="/demo/recording.m4a" controls preload="metadata">    <track kind="captions" src="/demo/recording.vtt" srclang="en" label="English">  </audio>  <section class="transcript" aria-label="Transcript" aria-controls="talk-audio" style="--transcript-height: 15rem">    <ol class="transcript-list scroll-area"></ol>    <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>      Back to current    </button>  </section></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="grid gap-sm max-w(480) mx-auto">    <audio id="talk-audio" class="w-full" src="/demo/recording.m4a" controls preload="metadata">      <track kind="captions" src="/demo/recording.vtt" srclang="en" label="English">    </audio>    <section class="transcript" aria-label="Transcript" aria-controls="talk-audio" style="--transcript-height: 15rem">      <ol class="transcript-list scroll-area"></ol>      <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>        Back to current      </button>    </section>  </div></template>
큐는 recording.vtt에서 읽어 옵니다. 스크립트가 없으면 이 목록은 비어 있으므로, 스크립트 없이도 읽어야 하는 경우에는 큐를 페이지에 작성하세요.

#동작

transcript는 transcript 클래스가 있는 루트 요소를 받아, 연결한 동작을 해제하는 함수를 반환합니다.

app.js
import { transcript } from '@master/ui/behaviors/transcript.js'const detach = transcript(document.querySelector('.transcript'))
  • 미디어는 aria-controls가 가리키는 요소입니다. 미디어 플레이어라면 그 player-media를 사용하며, <audio>나 <video>일 수도 있습니다. 동작은 미디어가 이벤트를 알릴 때마다 대상을 다시 찾으므로, 트랜스크립트보다 나중에 작성된 미디어나 나중에 지정한 다른 미디어도 따라갑니다. media 옵션을 사용하면 대신 다른 요소를 지정할 수 있습니다.
  • 큐는 시작 시점을 초 단위로 나타내는 data-start가 있는 li로, transcript-time 버튼과 transcript-text를 담습니다. 사용자가 문구를 선택하는 중이 아니라면 큐의 어디를 눌러도 그 시작 지점부터 재생됩니다. 시간 버튼에서 Enter 키를 눌러도 같습니다.
  • 다른 곳에서 작성한 행. 동작은 매번 목록을 읽고 아무것도 보관하지 않으므로, 렌더러가 큐를 작성하고 변경해도 됩니다. draw: false를 지정하면 빈 목록을 렌더러에 맡깁니다. track은 큐를 작성할 트랙을 고릅니다. 동작이 작성한 행은 동작을 해제할 때 제거됩니다.
옵션기본값
mediaaria-controls에서 가져옴따라갈 미디어 요소
track첫 번째 captions 또는 subtitles 트랙빈 목록을 작성할 때 사용하는 트랙
drawtrue빈 목록을 트랙에서 작성할지 여부

동작을 연결하지 않으면 큐는 사용자가 읽는 목록일 뿐입니다. 현재 큐는 따로 표시되지 않고 자동 스크롤도 작동하지 않습니다. 큐를 눌러도 재생 위치는 바뀌지 않습니다.

#키보드

현재 큐의 시간 버튼 하나만 탭 순서에 포함됩니다. 다른 시간 버튼으로 이동할 때는 방향키를 사용하므로 트랜스크립트가 길어도 탭 키를 반복해서 누를 필요가 없습니다.

키동작
TabTab으로 목록에 들어가면 현재 큐의 시각에, 없으면 첫 번째 큐의 시각에 포커스가 놓이고, 다시 Tab을 누르면 목록을 벗어납니다. 목록 전체가 하나의 탭 정지점입니다.
ArrowDown, ArrowUp다음 또는 이전 큐의 시각 버튼으로 포커스를 옮깁니다.
Home, End첫 번째 또는 마지막 큐의 시각 버튼으로 포커스를 옮깁니다.
Enter, Space네이티브 버튼과 마찬가지로 포커스가 있는 큐의 시각부터 재생합니다.

#접근성

  • aria-label이나, aria-labelledby로 가리키는 제목으로 트랜스크립트에 이름을 지정하고, aria-controls에 미디어를 지정하세요.
  • 현재 큐에는 aria-current="true"가 설정됩니다. 스타일시트는 글자색의 명암과 배경의 입체감으로 현재 큐를 구분하므로 색조에 의존하지 않습니다. 강제 색상 모드에서는 시스템 윤곽선으로 표시합니다.
  • 미디어가 재생되는 동안 트랜스크립트는 자동으로 포커스를 가져오지 않습니다. 포커스는 사용자가 옮길 때만 이동하며, 돌아가기 버튼을 고르면 현재 큐로 돌아갑니다.
  • 영상이 없는 녹음을 소리 없이 이해하려면 트랜스크립트가 필요합니다. 스크립트 없이도 페이지를 읽을 수 있어야 한다면 트랜스크립트를 페이지에 작성하세요.

#React, Svelte, Vue

transcript 컴포넌트는 각각 start, text, 선택 사항인 speaker로 이루어진 cues로 큐를 작성하고, media로 지정한 미디어를 연결 대상으로 지정한 뒤 동작을 연결합니다. 동작은 현재 큐를 표시하고 재생 위치에 맞춰 목록을 스크롤합니다. npx master-ui add transcript 명령을 실행해 프로젝트에 복사하세요. 컴포넌트의 구성과 사용 방법은 React, Svelte, Vue에서 확인할 수 있습니다.

ui/transcript.tsx
'use client'import { type ComponentProps } from 'react'import { clock, transcript } from '@master/ui/behaviors/transcript.js'import { useBehavior } from './use-behavior'export interface TranscriptCue {  /** The second the cue begins. */  start: number  /** What is said. */  text: string  /** Who says it, when the recording has several voices. */  speaker?: string}export interface TranscriptProps extends Omit<ComponentProps<'section'>, 'children' | 'ref'> {  /** The id of the player, or of the audio or video element, the transcript follows. */  media: string  /** The cues, in the order they are spoken. */  cues: TranscriptCue[]  /** The words of the button that brings the current cue back into view. */  returnLabel?: string}/** What a recording says, as cues that follow it as it plays. The rows are written from `cues`; the behavior marks and follows them. */export function Transcript({ media, cues, returnLabel = 'Back to current', className, ...root }: TranscriptProps) {  const ref = useBehavior(transcript, { draw: false })  return (    <section className={className ? `transcript ${className}` : 'transcript'} aria-controls={media} ref={ref} {...root}>      <ol className="transcript-list scroll-area">        {cues.map((cue, index) => (          <li className="transcript-cue" data-start={cue.start} key={`${cue.start}-${index}`}>            <button type="button" className="transcript-time">{clock(cue.start)}</button>            <p className="transcript-text">              {cue.speaker !== undefined && <span className="transcript-speaker">{cue.speaker}</span>}              {cue.text}            </p>          </li>        ))}      </ol>      <button type="button" className="btn btn-sm btn-pill transcript-return" hidden>{returnLabel}</button>    </section>  )}
ui/Transcript.svelte
<script lang="ts" module>  import type { HTMLAttributes } from 'svelte/elements'  export interface TranscriptCue {    /** The second the cue begins. */    start: number    /** What is said. */    text: string    /** Who says it, when the recording has several voices. */    speaker?: string  }  export interface TranscriptProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {    /** The id of the player, or of the audio or video element, the transcript follows. */    media: string    /** The cues, in the order they are spoken. */    cues: TranscriptCue[]    /** The words of the button that brings the current cue back into view. */    returnLabel?: string  }</script><script lang="ts">  import { clock, transcript } from '@master/ui/behaviors/transcript.js'  import { behavior } from './behavior.svelte.js'  let { media, cues, returnLabel = 'Back to current', class: className, ...root }: TranscriptProps = $props()  const attach = behavior(transcript, () => ({ draw: false }))</script><!--  @component  What a recording says, as cues that follow it as it plays. The rows are written from `cues`; the behavior marks and follows them.--><section class={['transcript', className]} aria-controls={media} {@attach attach} {...root}>  <ol class="transcript-list scroll-area">    {#each cues as cue, index (`${cue.start}-${index}`)}      <li class="transcript-cue" data-start={cue.start}>        <button type="button" class="transcript-time">{clock(cue.start)}</button>        <p class="transcript-text">          {#if cue.speaker !== undefined}<span class="transcript-speaker">{cue.speaker}</span>{/if}          {cue.text}        </p>      </li>    {/each}  </ol>  <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>{returnLabel}</button></section>
ui/Transcript.vue
<script setup lang="ts">import { useTemplateRef } from 'vue'import { clock, transcript } from '@master/ui/behaviors/transcript.js'import { useBehavior } from './use-behavior'defineOptions({ inheritAttrs: false })export interface TranscriptCue {  /** The second the cue begins. */  start: number  /** What is said. */  text: string  /** Who says it, when the recording has several voices. */  speaker?: string}const { returnLabel = 'Back to current' } = defineProps<{  /** The id of the player, or of the audio or video element, the transcript follows. */  media: string  /** The cues, in the order they are spoken. */  cues: TranscriptCue[]  /** The words of the button that brings the current cue back into view. */  returnLabel?: string}>()/* What a recording says, as cues that follow it as it plays. The rows are written from `cues`; the behavior marks and follows them. */const root = useTemplateRef<HTMLElement>('root')useBehavior(root, transcript, () => ({ draw: false }))</script><template>  <section class="transcript" :aria-controls="media" ref="root" v-bind="$attrs">    <ol class="transcript-list scroll-area">      <li v-for="(cue, index) in cues" :key="`${cue.start}-${index}`" class="transcript-cue" :data-start="cue.start">        <button type="button" class="transcript-time">{{ clock(cue.start) }}</button>        <p class="transcript-text">          <span v-if="cue.speaker !== undefined" class="transcript-speaker">{{ cue.speaker }}</span>          {{ cue.text }}        </p>      </li>    </ol>    <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>{{ returnLabel }}</button>  </section></template>

#클래스

클래스설명
transcript미디어 옆에 두는 트랜스크립트입니다. aria-label과, 따라가는 플레이어나 미디어 요소의 id를 담은 aria-controls를 지정하세요.
transcript-listol에 적용하는 큐 목록으로, --transcript-height 안에서 스크롤됩니다. 가장자리를 흐리게 하려면 scroll-area를 추가하세요.
transcript-cue큐 하나로, 시작하는 초를 data-start에 지정한 li입니다. 시각과 텍스트를 차례로 담습니다. 재생된 뒤에는 흐리게, 현재 큐일 때는 떠 있는 표면 위에 진하게 표시됩니다. 큐의 어느 곳을 눌러도 해당 시각부터 재생합니다.
transcript-time큐가 시작하는 시각을 작은 고정폭 숫자로 표시하는, 그 시점부터 재생하는 버튼입니다. 목록의 탭 정지점입니다.
transcript-text큐의 텍스트
transcript-speaker미디어에 여러 화자가 등장할 때 텍스트 위에 표시하는 화자 이름
transcript-return현재 큐로 돌아가는 버튼입니다. 목록 아래쪽 가장자리의 작은 캡슐형 버튼으로, 사용자가 스크롤해 현재 큐가 화면에서 벗어날 때까지 숨겨집니다.

돌아가기 버튼은 btn btn-sm btn-pill과 transcript-return 클래스를 함께 적용한 버튼입니다.

#사용자 지정 속성

속성기본값설명
--transcript-height20rem목록이 스크롤되기 전까지 커질 수 있는 최대 높이transcript에 설정합니다

#소스

@master/ui/components/transcript.css
/* * Transcript: what a recording says, as a list of cues that follows the media as it plays. * Each cue is a row with the time it begins, a small tabular button that is the row's way in from the keyboard, * and its words. Three inks say where the media is: a cue already played is quiet, the current cue * (aria-current="true") is strong and rests on a raised sheet, one step of depth like every current row, and the * cues still to come are in the body's ink. Played is derived from the current cue alone: every cue before it. * The list scrolls inside a height of its own (--transcript-height, 20rem) and the behavior keeps the current cue * in its middle. When the reader scrolls it away, the list stops following and a pill, transcript-return, stands * at its lower edge to bring it back. * Rows answer the pointer at once, with no fade. Without the behavior the cues are a list a reader reads, and * nothing is marked current. */@layer components.ui {  .transcript {    --transcript-height: 20rem;    --transcript-row-radius: var(--radius-control);    position: relative;    display: flex;    flex-direction: column;    min-width: 0;    min-height: 0;    margin: 0;  }  /* The cues, in a scroller of their own. Add scroll-area to fade the edges where the list goes on. */  .transcript-list {    display: grid;    align-content: start;    gap: 2px;    min-height: 0;    max-height: var(--transcript-height);    margin: 0;    padding: .25rem;    overflow: auto;    overscroll-behavior: contain;    list-style: none;    scroll-padding-block: 1rem;    /* The script listens on the whole list for a press on a cue: a tap must not flash the list grey on iOS. */    -webkit-tap-highlight-color: transparent;    /*     * The times share one column across the list, as wide as the longest: past an hour a time is wider than     * the column's least width, and the words of every cue still start on one line. Without subgrid each cue     * sizes its own column, which is the same until a time outgrows that least width.     */    @supports (grid-template-columns: subgrid) {      grid-template-columns: auto minmax(0, 1fr);    }  }  /* One cue: its time, then its words. The whole row seeks under the pointer. */  .transcript-cue {    display: grid;    grid-template-columns: auto minmax(0, 1fr);    align-items: baseline;    gap: .375rem;    margin: 0;    padding-block: .375rem;    padding-inline: .25rem .625rem;    border-radius: calc(var(--transcript-row-radius) * var(--corner-scale));    corner-shape: var(--corner-shape);    color: var(--color-text-body);    cursor: pointer;    -webkit-tap-highlight-color: transparent;    touch-action: manipulation;    @supports (grid-template-columns: subgrid) {      grid-column: 1 / -1;      grid-template-columns: subgrid;    }    /* A cue a search filters out is hidden: the grid above would otherwise beat the browser's own [hidden]. */    &[hidden] {      display: none;    }    /* A cue is a full-width row of a list: on touch a one-line cue is 44px tall, the target a finger is owed. */    @media (pointer: coarse) {      min-height: 2.75rem;      align-content: center;    }    @media (hover: hover) {      &:hover:not([aria-current="true"]) {        background: var(--color-surface-inset);      }    }    /* Pressed: a step deeper than the pointer's tone, so a tap on a cue is answered where there is no pointer. */    &:active:not([aria-current="true"]) {      background: var(--color-surface-inset-hover);    }    /* Already played: every cue before the current one. */    &:has(~ .transcript-cue[aria-current="true"]) {      color: var(--color-text-muted);    }    /* The cue being spoken: strong ink on a raised sheet. */    &[aria-current="true"] {      @apply --surface-sheet;      color: var(--color-text-strong);      box-shadow: var(--shadow-raised);    }    @media (forced-colors: active) {      &[aria-current="true"] {        outline: 2px solid Highlight;        outline-offset: -2px;      }    }  }  /* When the cue begins, as a button: Enter or a press on it plays from there. */  .transcript-time {    min-width: 2.75rem;    margin: 0;    padding: .1875rem .375rem;    border: 0;    border-radius: calc(var(--radius-chip) * var(--corner-scale));    corner-shape: var(--corner-shape);    background: transparent;    color: var(--color-text-muted);    font: var(--font-weight-control) .75rem/1.2 var(--font-family-sans);    font-variant-numeric: tabular-nums;    text-align: end;    appearance: none;    cursor: pointer;    -webkit-tap-highlight-color: transparent;    .transcript-cue[aria-current="true"] & {      color: var(--color-text-strong);    }    &:focus-visible {      @apply --focus-ring;      outline-offset: 0;    }    @media (forced-colors: active) {      &:focus-visible {        outline-color: Highlight;      }    }  }  /* The words of a cue. */  .transcript-text {    margin: 0;    font-size: .875rem;    line-height: 1.5;    text-wrap: pretty;    overflow-wrap: anywhere;  }  /* Who speaks, before the words, when the recording has several voices. */  .transcript-speaker {    display: block;    margin: 0;    color: var(--color-text-strong);    font-size: .75rem;    font-weight: var(--font-weight-control);    line-height: 1.5;  }  /*   * Back to the current cue: a pill at the list's lower edge, shown only while the reader has scrolled away.   * Write it as a small button (btn btn-sm btn-pill); this part places it and lets it fade in.   */  .transcript-return {    position: absolute;    inset-inline: 0;    bottom: .75rem;    width: fit-content;    margin-inline: auto;    transition-property: opacity, display, box-shadow, translate, color;    transition-behavior: allow-discrete;    &[hidden] {      display: none;      opacity: 0;    }    @starting-style {      opacity: 0;    }  }}