@gentomiyano/optimized-web-audio-player 0.2.2 → 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.
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,
@@ -885,77 +956,48 @@ function BoundCompactPlayerView({
885
956
  runtimeStatus,
886
957
  state
887
958
  }) {
888
- const progress = state.durationSec === null || state.durationSec <= 0 ? 0 : state.currentTimeSec / state.durationSec;
889
959
  return /* @__PURE__ */ jsx(
890
- PlayerSurface,
960
+ CompactPlayerLayout,
891
961
  {
892
962
  appearance,
893
- 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,
894
971
  label: `Inline player: ${state.item.title}`,
895
- children: /* @__PURE__ */ jsxs(
896
- "div",
972
+ primaryControl: /* @__PURE__ */ jsx(
973
+ IconButton,
897
974
  {
898
- className: "player-bound-compact__main",
899
- "data-active": state.isActive ? "true" : "false",
900
- "data-playback-context-id": contextId,
901
- "data-playback-context-mode": contextMode,
902
- "data-player-runtime-status": runtimeStatus,
903
- "data-queue-item-id": state.queueItemId,
904
- children: [
905
- /* @__PURE__ */ jsx(
906
- IconButton,
907
- {
908
- className: "player-play-button",
909
- label: state.isPlaying ? "Pause" : "Play",
910
- onClick: () => {
911
- void commands.togglePlayback();
912
- },
913
- children: state.isPlaying ? /* @__PURE__ */ jsx(PauseIcon, { size: 22 }) : /* @__PURE__ */ jsx(PlayIcon, { size: 22 })
914
- }
915
- ),
916
- /* @__PURE__ */ jsx(
917
- Artwork,
918
- {
919
- className: "player-bound-compact__artwork",
920
- item: state.item
921
- }
922
- ),
923
- /* @__PURE__ */ jsx(TrackMetadata, { item: state.item, scrollTitle: state.isPlaying }),
924
- /* @__PURE__ */ jsxs("div", { className: "player-bound-compact__signal", children: [
925
- /* @__PURE__ */ jsx(
926
- Waveform,
927
- {
928
- opacity: options.waveformOpacity,
929
- playedStateEnabled: options.waveformPlayedStateEnabled,
930
- progress,
931
- waveform: state.item.waveform
932
- }
933
- ),
934
- /* @__PURE__ */ jsx(
935
- TimeReadout,
936
- {
937
- currentTimeSec: state.currentTimeSec,
938
- durationSec: state.durationSec
939
- }
940
- )
941
- ] }),
942
- /* @__PURE__ */ jsx(
943
- SeekBar,
944
- {
945
- canSeek: state.canSeek,
946
- commitMode: options.seekCommitMode,
947
- currentTimeSec: state.currentTimeSec,
948
- durationSec: state.durationSec,
949
- label: `Seek in ${state.item.title}`,
950
- onSeek: (seconds) => {
951
- commands.seekTo(seconds);
952
- },
953
- status: state.status
954
- }
955
- )
956
- ]
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
957
997
  }
958
- )
998
+ ),
999
+ waveformOpacity: options.waveformOpacity,
1000
+ waveformPlayedStateEnabled: options.waveformPlayedStateEnabled
959
1001
  }
960
1002
  );
961
1003
  }