@waveform-playlist/browser 5.0.0-alpha.12 → 5.0.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import { default as default_3 } from 'waveform-data';
4
4
  import { DragEndEvent } from '@dnd-kit/core';
5
5
  import { Fade as Fade_2 } from '@waveform-playlist/core';
6
6
  import { Gain } from 'tone';
7
+ import { MediaElementPlayout } from '@waveform-playlist/media-element-playout';
7
8
  import { MutableRefObject } from 'react';
8
9
  import react__default from 'react';
9
10
  import { ReactNode } from 'react';
@@ -50,7 +51,7 @@ declare interface AnnotationActionOptions {
50
51
  [key: string]: unknown;
51
52
  }
52
53
 
53
- declare interface AnnotationData {
54
+ export declare interface AnnotationData {
54
55
  id: string;
55
56
  start: number;
56
57
  end: number;
@@ -530,6 +531,141 @@ export declare interface MasterVolumeControls {
530
531
  setMasterVolume: (volume: number) => void;
531
532
  }
532
533
 
534
+ export declare interface MediaElementAnimationContextValue {
535
+ isPlaying: boolean;
536
+ currentTime: number;
537
+ currentTimeRef: default_2.RefObject<number>;
538
+ }
539
+
540
+ export declare interface MediaElementControlsContextValue {
541
+ play: (startTime?: number) => void;
542
+ pause: () => void;
543
+ stop: () => void;
544
+ seekTo: (time: number) => void;
545
+ setPlaybackRate: (rate: number) => void;
546
+ setContinuousPlay: (enabled: boolean) => void;
547
+ setAnnotations: (annotations: AnnotationData[]) => void;
548
+ setActiveAnnotationId: (id: string | null) => void;
549
+ }
550
+
551
+ export declare interface MediaElementDataContextValue {
552
+ duration: number;
553
+ peaksDataArray: TrackClipPeaks[];
554
+ sampleRate: number;
555
+ waveHeight: number;
556
+ timeScaleHeight: number;
557
+ samplesPerPixel: number;
558
+ playoutRef: default_2.RefObject<MediaElementPlayout | null>;
559
+ controls: {
560
+ show: boolean;
561
+ width: number;
562
+ };
563
+ barWidth: number;
564
+ barGap: number;
565
+ progressBarWidth: number;
566
+ }
567
+
568
+ /**
569
+ * MediaElementPlaylistProvider
570
+ *
571
+ * A simplified playlist provider for single-track playback using HTMLAudioElement.
572
+ * Key features:
573
+ * - Pitch-preserving playback rate (0.5x - 2.0x)
574
+ * - Pre-computed peaks visualization (no AudioBuffer needed)
575
+ * - Simpler API than full WaveformPlaylistProvider
576
+ *
577
+ * Use this for:
578
+ * - Language learning apps (speed control)
579
+ * - Podcast players
580
+ * - Single-track audio viewers
581
+ *
582
+ * For multi-track editing, use WaveformPlaylistProvider instead.
583
+ */
584
+ export declare const MediaElementPlaylistProvider: default_2.FC<MediaElementPlaylistProviderProps>;
585
+
586
+ declare interface MediaElementPlaylistProviderProps {
587
+ /** Single track configuration with source URL and waveform data */
588
+ track: MediaElementTrackConfig;
589
+ /** Initial samples per pixel (zoom level) */
590
+ samplesPerPixel?: number;
591
+ /** Height of each waveform track */
592
+ waveHeight?: number;
593
+ /** Show timescale */
594
+ timescale?: boolean;
595
+ /** Initial playback rate (0.5 to 2.0) */
596
+ playbackRate?: number;
597
+ /** Theme configuration */
598
+ theme?: Partial<WaveformPlaylistTheme>;
599
+ /** Track controls configuration */
600
+ controls?: {
601
+ show: boolean;
602
+ width: number;
603
+ };
604
+ /** Annotations */
605
+ annotationList?: {
606
+ annotations?: any[];
607
+ isContinuousPlay?: boolean;
608
+ };
609
+ /** Width of waveform bars */
610
+ barWidth?: number;
611
+ /** Gap between waveform bars */
612
+ barGap?: number;
613
+ /** Width of progress bars */
614
+ progressBarWidth?: number;
615
+ /** Callback when audio is ready */
616
+ onReady?: () => void;
617
+ children: ReactNode;
618
+ }
619
+
620
+ export declare interface MediaElementStateContextValue {
621
+ continuousPlay: boolean;
622
+ annotations: AnnotationData[];
623
+ activeAnnotationId: string | null;
624
+ playbackRate: number;
625
+ }
626
+
627
+ export declare interface MediaElementTrackConfig {
628
+ /** Audio source URL or Blob URL */
629
+ source: string;
630
+ /** Pre-computed waveform data (required for visualization) */
631
+ waveformData: WaveformDataObject;
632
+ /** Track name for display */
633
+ name?: string;
634
+ }
635
+
636
+ /**
637
+ * Simplified Waveform component for MediaElementPlaylistProvider
638
+ *
639
+ * This is a stripped-down version of Waveform that works with the
640
+ * MediaElement context. It supports:
641
+ * - Single track visualization
642
+ * - Click to seek
643
+ * - Annotation display and click-to-play
644
+ * - Playhead animation
645
+ *
646
+ * For multi-track editing, use the full Waveform with WaveformPlaylistProvider.
647
+ */
648
+ export declare const MediaElementWaveform: default_2.FC<MediaElementWaveformProps>;
649
+
650
+ export declare interface MediaElementWaveformProps {
651
+ /** Height in pixels for the annotation text list */
652
+ annotationTextHeight?: number;
653
+ /** Custom function to generate the label shown on annotation boxes */
654
+ getAnnotationBoxLabel?: (annotation: {
655
+ id: string;
656
+ start: number;
657
+ end: number;
658
+ lines: string[];
659
+ }) => string;
660
+ /**
661
+ * Custom render function for annotation items in the text list.
662
+ * When provided, completely replaces the default annotation item rendering.
663
+ * Use this to customize the appearance of each annotation (e.g., add furigana).
664
+ */
665
+ renderAnnotationItem?: (props: RenderAnnotationItemProps) => default_2.ReactNode;
666
+ className?: string;
667
+ }
668
+
533
669
  declare interface MicrophoneDevice {
534
670
  deviceId: string;
535
671
  label: string;
@@ -673,6 +809,17 @@ declare interface PlaylistStateContextValue {
673
809
  loopEnd: number;
674
810
  }
675
811
 
812
+ /**
813
+ * Props passed to the renderAnnotationItem function for custom rendering
814
+ */
815
+ export declare interface RenderAnnotationItemProps {
816
+ annotation: AnnotationData;
817
+ index: number;
818
+ isActive: boolean;
819
+ onClick: () => void;
820
+ formatTime: (seconds: number) => string;
821
+ }
822
+
676
823
  /**
677
824
  * Type for custom playhead render functions.
678
825
  * Receives position, color, and animation refs for smooth 60fps animation.
@@ -1303,6 +1450,14 @@ declare interface UseMasterVolumeProps {
1303
1450
  onVolumeChange?: (volume: number) => void;
1304
1451
  }
1305
1452
 
1453
+ export declare const useMediaElementAnimation: () => MediaElementAnimationContextValue;
1454
+
1455
+ export declare const useMediaElementControls: () => MediaElementControlsContextValue;
1456
+
1457
+ export declare const useMediaElementData: () => MediaElementDataContextValue;
1458
+
1459
+ export declare const useMediaElementState: () => MediaElementStateContextValue;
1460
+
1306
1461
  export declare const usePlaybackAnimation: () => PlaybackAnimationContextValue;
1307
1462
 
1308
1463
  /**
@@ -1653,6 +1808,22 @@ export declare interface WaveformProps {
1653
1808
  annotationControls?: AnnotationAction[];
1654
1809
  annotationListConfig?: AnnotationActionOptions;
1655
1810
  annotationTextHeight?: number;
1811
+ /**
1812
+ * Custom render function for annotation items in the text list.
1813
+ * Use this to completely customize how each annotation is displayed.
1814
+ */
1815
+ renderAnnotationItem?: (props: RenderAnnotationItemProps) => ReactNode;
1816
+ /**
1817
+ * Custom function to generate the label shown on annotation boxes in the waveform.
1818
+ * Receives the annotation data and should return a string label.
1819
+ * Default: annotation.id
1820
+ */
1821
+ getAnnotationBoxLabel?: (annotation: {
1822
+ id: string;
1823
+ start: number;
1824
+ end: number;
1825
+ lines: string[];
1826
+ }) => string;
1656
1827
  className?: string;
1657
1828
  showClipHeaders?: boolean;
1658
1829
  interactiveClips?: boolean;