@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/README.md +14 -0
- package/dist/react/index.js +212 -159
- package/dist/react/index.js.map +1 -1
- package/dist/ui/index.js +151 -109
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/player-views.css +37 -59
- package/package.json +1 -1
package/dist/ui/index.js
CHANGED
|
@@ -724,59 +724,84 @@ function Waveform({
|
|
|
724
724
|
}
|
|
725
725
|
);
|
|
726
726
|
}
|
|
727
|
-
function
|
|
727
|
+
function CompactPlayerLayout({
|
|
728
728
|
appearance,
|
|
729
729
|
className,
|
|
730
|
-
|
|
731
|
-
|
|
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 =
|
|
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
|
|
754
|
+
label,
|
|
740
755
|
children: [
|
|
741
|
-
/* @__PURE__ */ jsxs(
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
{
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
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
|
-
|
|
960
|
+
CompactPlayerLayout,
|
|
891
961
|
{
|
|
892
962
|
appearance,
|
|
893
|
-
className:
|
|
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
|
-
|
|
896
|
-
|
|
972
|
+
primaryControl: /* @__PURE__ */ jsx(
|
|
973
|
+
IconButton,
|
|
897
974
|
{
|
|
898
|
-
className: "player-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
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
|
}
|