@gentomiyano/optimized-web-audio-player 0.2.1 → 0.2.3

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.
@@ -1,4 +1,4 @@
1
- import { u as PlayerMediaAdapter, v as PlayerMediaItem, Q as QueueItem, n as PlayerError, y as PlayerState, p as PlayerExperienceConfig } from '../player-BxNFzRq4.js';
1
+ import { u as PlayerMediaAdapter, v as PlayerMediaItem, Q as QueueItem, n as PlayerError, z as PlayerState, p as PlayerExperienceConfig } from '../player-CE714iU_.js';
2
2
 
3
3
  type MockPlayerScenario = "success" | "loading" | "duration-unknown" | "missing-waveform" | "recoverable-error" | "fatal-error";
4
4
  interface MockMediaRecord {
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { C as PlayerViewProps, h as PlayerAppearance, B as BoundPlayerCommands, a as BoundPlayerViewState, S as SeekCommitMode, d as PlaybackContextMode, v as PlayerMediaItem, y as PlayerState, j as PlayerCommands, n as PlayerError, R as RepeatMode, f as PlaybackStatus, D as PlayerWaveform } from '../player-BxNFzRq4.js';
3
+ import { D as PlayerViewProps, h as PlayerAppearance, B as BoundPlayerCommands, a as BoundPlayerViewState, S as SeekCommitMode, d as PlaybackContextMode, y as PlayerRuntimeStatus, v as PlayerMediaItem, z as PlayerState, j as PlayerCommands, n as PlayerError, R as RepeatMode, f as PlaybackStatus, E as PlayerWaveform } from '../player-CE714iU_.js';
4
4
 
5
5
  interface CompactPlayerProps extends PlayerViewProps {
6
6
  readonly className?: string;
@@ -20,8 +20,9 @@ interface BoundCompactPlayerViewProps {
20
20
  readonly className?: string;
21
21
  readonly contextId?: string;
22
22
  readonly contextMode?: PlaybackContextMode;
23
+ readonly runtimeStatus?: PlayerRuntimeStatus;
23
24
  }
24
- declare function BoundCompactPlayerView({ appearance, className, commands, contextId, contextMode, options, state, }: BoundCompactPlayerViewProps): react.JSX.Element;
25
+ declare function BoundCompactPlayerView({ appearance, className, commands, contextId, contextMode, options, runtimeStatus, state, }: BoundCompactPlayerViewProps): react.JSX.Element;
25
26
 
26
27
  interface DetailedPlayerProps extends PlayerViewProps {
27
28
  readonly className?: string;
package/dist/ui/index.js CHANGED
@@ -724,59 +724,84 @@ function Waveform({
724
724
  }
725
725
  );
726
726
  }
727
- function CompactPlayer({
727
+ function CompactPlayerLayout({
728
728
  appearance,
729
729
  className,
730
- commands,
731
- state
730
+ contextId,
731
+ contextMode,
732
+ currentTimeSec,
733
+ durationSec,
734
+ errorNotice,
735
+ isActive,
736
+ isPlaying,
737
+ item,
738
+ label,
739
+ primaryControl,
740
+ queueItemId,
741
+ runtimeStatus,
742
+ seekControl,
743
+ status,
744
+ trailingControl,
745
+ waveformOpacity,
746
+ waveformPlayedStateEnabled
732
747
  }) {
733
- const progress = state.durationSec === null || state.durationSec <= 0 ? 0 : state.currentTimeSec / state.durationSec;
748
+ const progress = durationSec === null || durationSec <= 0 ? 0 : currentTimeSec / durationSec;
734
749
  return /* @__PURE__ */ jsxs(
735
750
  PlayerSurface,
736
751
  {
737
752
  appearance,
738
753
  className: ["player-compact", className].filter(Boolean).join(" "),
739
- label: "Compact music player",
754
+ label,
740
755
  children: [
741
- /* @__PURE__ */ jsxs("div", { className: "player-compact__main", children: [
742
- /* @__PURE__ */ jsx(PrimaryPlaybackButton, { commands, state }),
743
- /* @__PURE__ */ jsx(Artwork, { className: "player-compact__artwork", item: state.currentItem }),
744
- /* @__PURE__ */ jsx(
745
- TrackMetadata,
746
- {
747
- item: state.currentItem,
748
- scrollTitle: state.status === "playing"
749
- }
750
- ),
751
- /* @__PURE__ */ jsxs("div", { className: "player-compact__signal", children: [
752
- /* @__PURE__ */ jsx(PlayerStatus, { state }),
753
- /* @__PURE__ */ jsx(
754
- Waveform,
755
- {
756
- opacity: state.experienceConfig.waveformOpacity,
757
- playedStateEnabled: state.experienceConfig.waveformPlayedStateEnabled,
758
- progress,
759
- waveform: state.currentItem?.waveform
760
- }
761
- ),
762
- /* @__PURE__ */ jsx(
763
- TimeReadout,
764
- {
765
- currentTimeSec: state.currentTimeSec,
766
- durationSec: state.durationSec
767
- }
768
- )
769
- ] }),
770
- /* @__PURE__ */ jsx(
771
- PopoverVolumeControl,
772
- {
773
- commands,
774
- label: "Compact volume",
775
- state
776
- }
777
- )
778
- ] }),
779
- /* @__PURE__ */ jsx(PlayerErrorNotice, { commands, state })
756
+ /* @__PURE__ */ jsxs(
757
+ "div",
758
+ {
759
+ className: "player-compact__main",
760
+ ...isActive === void 0 ? {} : { "data-active": isActive ? "true" : "false" },
761
+ "data-has-status": status === void 0 ? "false" : "true",
762
+ "data-has-trailing-control": trailingControl === void 0 ? "false" : "true",
763
+ "data-playback-context-id": contextId,
764
+ "data-playback-context-mode": contextMode,
765
+ "data-player-runtime-status": runtimeStatus,
766
+ "data-queue-item-id": queueItemId,
767
+ children: [
768
+ primaryControl,
769
+ /* @__PURE__ */ jsx(Artwork, { className: "player-compact__artwork", item }),
770
+ /* @__PURE__ */ jsx(TrackMetadata, { item, scrollTitle: isPlaying }),
771
+ /* @__PURE__ */ jsxs("div", { className: "player-compact__signal", children: [
772
+ status,
773
+ /* @__PURE__ */ jsxs(
774
+ "div",
775
+ {
776
+ className: "player-compact__scrubber",
777
+ "data-seek-enabled": seekControl === void 0 ? "false" : "true",
778
+ children: [
779
+ /* @__PURE__ */ jsx(
780
+ Waveform,
781
+ {
782
+ opacity: waveformOpacity,
783
+ playedStateEnabled: waveformPlayedStateEnabled,
784
+ progress,
785
+ waveform: item?.waveform
786
+ }
787
+ ),
788
+ seekControl
789
+ ]
790
+ }
791
+ ),
792
+ /* @__PURE__ */ jsx(
793
+ TimeReadout,
794
+ {
795
+ currentTimeSec,
796
+ durationSec
797
+ }
798
+ )
799
+ ] }),
800
+ trailingControl
801
+ ]
802
+ }
803
+ ),
804
+ errorNotice
780
805
  ]
781
806
  }
782
807
  );
@@ -875,6 +900,52 @@ function SeekBar({
875
900
  }
876
901
  );
877
902
  }
903
+ function CompactPlayer({
904
+ appearance,
905
+ className,
906
+ commands,
907
+ state
908
+ }) {
909
+ return /* @__PURE__ */ jsx(
910
+ CompactPlayerLayout,
911
+ {
912
+ appearance,
913
+ ...className === void 0 ? {} : { className },
914
+ currentTimeSec: state.currentTimeSec,
915
+ durationSec: state.durationSec,
916
+ errorNotice: /* @__PURE__ */ jsx(PlayerErrorNotice, { commands, state }),
917
+ isPlaying: state.status === "playing",
918
+ item: state.currentItem,
919
+ label: "Compact music player",
920
+ primaryControl: /* @__PURE__ */ jsx(PrimaryPlaybackButton, { commands, state }),
921
+ seekControl: /* @__PURE__ */ jsx(
922
+ SeekBar,
923
+ {
924
+ canSeek: state.canSeek,
925
+ commitMode: state.experienceConfig.seekCommitMode,
926
+ currentTimeSec: state.currentTimeSec,
927
+ durationSec: state.durationSec,
928
+ label: `Seek in ${state.currentItem?.title ?? "current media"}`,
929
+ onSeek: (seconds) => {
930
+ commands.seekTo(seconds);
931
+ },
932
+ status: state.status
933
+ }
934
+ ),
935
+ status: /* @__PURE__ */ jsx(PlayerStatus, { state }),
936
+ trailingControl: /* @__PURE__ */ jsx(
937
+ PopoverVolumeControl,
938
+ {
939
+ commands,
940
+ label: "Compact volume",
941
+ state
942
+ }
943
+ ),
944
+ waveformOpacity: state.experienceConfig.waveformOpacity,
945
+ waveformPlayedStateEnabled: state.experienceConfig.waveformPlayedStateEnabled
946
+ }
947
+ );
948
+ }
878
949
  function BoundCompactPlayerView({
879
950
  appearance,
880
951
  className,
@@ -882,78 +953,51 @@ function BoundCompactPlayerView({
882
953
  contextId,
883
954
  contextMode,
884
955
  options,
956
+ runtimeStatus,
885
957
  state
886
958
  }) {
887
- const progress = state.durationSec === null || state.durationSec <= 0 ? 0 : state.currentTimeSec / state.durationSec;
888
959
  return /* @__PURE__ */ jsx(
889
- PlayerSurface,
960
+ CompactPlayerLayout,
890
961
  {
891
962
  appearance,
892
- className: ["player-bound-compact", className].filter(Boolean).join(" "),
963
+ ...className === void 0 ? {} : { className },
964
+ ...contextId === void 0 ? {} : { contextId },
965
+ ...contextMode === void 0 ? {} : { contextMode },
966
+ currentTimeSec: state.currentTimeSec,
967
+ durationSec: state.durationSec,
968
+ isActive: state.isActive,
969
+ isPlaying: state.isPlaying,
970
+ item: state.item,
893
971
  label: `Inline player: ${state.item.title}`,
894
- children: /* @__PURE__ */ jsxs(
895
- "div",
972
+ primaryControl: /* @__PURE__ */ jsx(
973
+ IconButton,
896
974
  {
897
- className: "player-bound-compact__main",
898
- "data-active": state.isActive ? "true" : "false",
899
- "data-playback-context-id": contextId,
900
- "data-playback-context-mode": contextMode,
901
- "data-queue-item-id": state.queueItemId,
902
- children: [
903
- /* @__PURE__ */ jsx(
904
- IconButton,
905
- {
906
- className: "player-play-button",
907
- label: state.isPlaying ? "Pause" : "Play",
908
- onClick: () => {
909
- void commands.togglePlayback();
910
- },
911
- children: state.isPlaying ? /* @__PURE__ */ jsx(PauseIcon, { size: 22 }) : /* @__PURE__ */ jsx(PlayIcon, { size: 22 })
912
- }
913
- ),
914
- /* @__PURE__ */ jsx(
915
- Artwork,
916
- {
917
- className: "player-bound-compact__artwork",
918
- item: state.item
919
- }
920
- ),
921
- /* @__PURE__ */ jsx(TrackMetadata, { item: state.item, scrollTitle: state.isPlaying }),
922
- /* @__PURE__ */ jsxs("div", { className: "player-bound-compact__signal", children: [
923
- /* @__PURE__ */ jsx(
924
- Waveform,
925
- {
926
- opacity: options.waveformOpacity,
927
- playedStateEnabled: options.waveformPlayedStateEnabled,
928
- progress,
929
- waveform: state.item.waveform
930
- }
931
- ),
932
- /* @__PURE__ */ jsx(
933
- TimeReadout,
934
- {
935
- currentTimeSec: state.currentTimeSec,
936
- durationSec: state.durationSec
937
- }
938
- )
939
- ] }),
940
- /* @__PURE__ */ jsx(
941
- SeekBar,
942
- {
943
- canSeek: state.canSeek,
944
- commitMode: options.seekCommitMode,
945
- currentTimeSec: state.currentTimeSec,
946
- durationSec: state.durationSec,
947
- label: `Seek in ${state.item.title}`,
948
- onSeek: (seconds) => {
949
- commands.seekTo(seconds);
950
- },
951
- status: state.status
952
- }
953
- )
954
- ]
975
+ className: "player-play-button",
976
+ label: state.isPlaying ? "Pause" : "Play",
977
+ onClick: () => {
978
+ void commands.togglePlayback();
979
+ },
980
+ children: state.isPlaying ? /* @__PURE__ */ jsx(PauseIcon, { size: 22 }) : /* @__PURE__ */ jsx(PlayIcon, { size: 22 })
981
+ }
982
+ ),
983
+ queueItemId: state.queueItemId,
984
+ ...runtimeStatus === void 0 ? {} : { runtimeStatus },
985
+ seekControl: /* @__PURE__ */ jsx(
986
+ SeekBar,
987
+ {
988
+ canSeek: state.canSeek,
989
+ commitMode: options.seekCommitMode,
990
+ currentTimeSec: state.currentTimeSec,
991
+ durationSec: state.durationSec,
992
+ label: `Seek in ${state.item.title}`,
993
+ onSeek: (seconds) => {
994
+ commands.seekTo(seconds);
995
+ },
996
+ status: state.status
955
997
  }
956
- )
998
+ ),
999
+ waveformOpacity: options.waveformOpacity,
1000
+ waveformPlayedStateEnabled: options.waveformPlayedStateEnabled
957
1001
  }
958
1002
  );
959
1003
  }