aplayer-react
Advanced tools
Comparing version 1.0.2 to 1.0.3-alpha.1
@@ -18,3 +18,3 @@ declare type AudioInfo = { | ||
declare type APlayerProps = { | ||
audio: AudioInfo | AudioInfo[]; | ||
audio: AudioInfo | readonly AudioInfo[]; | ||
theme?: string; | ||
@@ -21,0 +21,0 @@ /** |
@@ -181,8 +181,7 @@ "use strict"; | ||
}) { | ||
const wrapperRef = (0, import_react.useRef)(null); | ||
const handleMouseDown = (0, import_react.useCallback)( | ||
(e) => { | ||
const barDimensions = wrapperRef.current?.getBoundingClientRect(); | ||
const barDimensions = e.currentTarget.getBoundingClientRect(); | ||
const deltaX = e.clientX - barDimensions.x; | ||
const percentage = deltaX / barDimensions?.width; | ||
const percentage = deltaX / barDimensions.width; | ||
onSeek?.(percentage); | ||
@@ -192,37 +191,29 @@ }, | ||
); | ||
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( | ||
"div", | ||
{ | ||
ref: wrapperRef, | ||
className: "aplayer-bar-wrap", | ||
onMouseDown: handleMouseDown, | ||
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "aplayer-bar", children: [ | ||
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)( | ||
"div", | ||
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "aplayer-bar-wrap", onMouseDown: handleMouseDown, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "aplayer-bar", children: [ | ||
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)( | ||
"div", | ||
{ | ||
className: "aplayer-loaded", | ||
style: { width: `${bufferedPercentage * 100}%` } | ||
} | ||
), | ||
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)( | ||
"div", | ||
{ | ||
className: "aplayer-played", | ||
style: { | ||
width: `${playedPercentage * 100}%`, | ||
backgroundColor: themeColor | ||
}, | ||
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( | ||
"span", | ||
{ | ||
className: "aplayer-loaded", | ||
style: { width: `${bufferedPercentage * 100}%` } | ||
className: "aplayer-thumb", | ||
style: { backgroundColor: themeColor }, | ||
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "aplayer-loading-icon", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SvgLoading, {}) }) | ||
} | ||
), | ||
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)( | ||
"div", | ||
{ | ||
className: "aplayer-played", | ||
style: { | ||
width: `${playedPercentage * 100}%`, | ||
backgroundColor: themeColor | ||
}, | ||
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( | ||
"span", | ||
{ | ||
className: "aplayer-thumb", | ||
style: { backgroundColor: themeColor }, | ||
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "aplayer-loading-icon", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SvgLoading, {}) }) | ||
} | ||
) | ||
} | ||
) | ||
] }) | ||
} | ||
); | ||
} | ||
) | ||
] }) }); | ||
} | ||
@@ -229,0 +220,0 @@ |
{ | ||
"name": "aplayer-react", | ||
"version": "1.0.2", | ||
"version": "1.0.3-alpha.1", | ||
"description": "The missing APlayer for React applications", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -7,2 +7,4 @@ # aplayer-react | ||
View full documentation on https://aplayer-react.vercel.app | ||
## Features | ||
@@ -41,19 +43,2 @@ | ||
### Props | ||
| Prop | Default | Description | | ||
| ------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------ | | ||
| audio | | Songs' information. Could be a single object or an array of objects | | ||
| audio.name | `"Audio name"` | Title of the song | | ||
| audio.artist | `"Audio artist"` | Artist name of the song | | ||
| audio.url | | Url of the media source to play | | ||
| audio.cover | | Url of the album cover image | | ||
| audio.lrc | | Lyrics of the song in raw LRC format | | ||
| audio.theme | | Override theme color for this song. See `theme` prop for theme color explanation | | ||
| theme | `"#ebd0c2"` | Theme color of the player that applies to progress bar, volume control bar and playlist marker. | | ||
| autoPlay | | [See `autoplay` attribute of `<audio>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio#attr-autoplay) | | ||
| volume | `0.7` | Initial volume of the player. | | ||
| initialLoop | `"all"` | Initial loop mode of the player | | ||
| initialOrder | `"list"` | Initial playlist order of the player | | ||
## Who uses aplayer-react? | ||
@@ -60,0 +45,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72727
1811
1
50