react-modern-audio-player 1.1.4 → 1.1.5

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.cjs CHANGED
@@ -8,7 +8,7 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
8
8
  *
9
9
  * This source code is licensed under the MIT license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
- */var Yc=W.default,qc=Symbol.for("react.element"),Jc=Symbol.for("react.fragment"),Qc=Object.prototype.hasOwnProperty,Zc=Yc.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ef={key:!0,ref:!0,__self:!0,__source:!0};function Po(e,t,r){var n,a={},i=null,s=null;r!==void 0&&(i=""+r),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)Qc.call(t,n)&&!ef.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)a[n]===void 0&&(a[n]=t[n]);return{$$typeof:qc,type:e,key:i,ref:s,props:a,_owner:Zc.current}}sr.Fragment=Jc;sr.jsx=Po;sr.jsxs=Po;or.exports=sr;const L=or.exports.jsx,le=or.exports.jsxs,ze=or.exports.Fragment,tf=({children:e,rootContainerProps:t})=>{const{playerPlacement:r}=j(Z),[n,a]=x.useState();return x.useLayoutEffect(()=>{r&&a((()=>{switch(r){case"bottom":return{bottom:0};case"top":return{top:0};case"bottom-left":return{bottom:0,left:0};case"bottom-right":return{bottom:0,right:0};case"top-left":return{top:0,left:0};case"top-right":return{top:0,right:0}}})())},[r]),L(yo,{theme:Xc,width:"100%",position:r&&"fixed",UNSAFE_className:"rm-audio-player-provider",...n,...t,children:e})},ce=x.createContext(null),Hn=e=>{const t=`${Math.floor(e/60)}`.padStart(2,"0"),r=`${Math.floor(e%60)}`.padStart(2,"0");return`${t}:${r}`},Fn=(e,t,r)=>{if(!e)return;const{progressHandleEl:n,progressValueEl:a,trackCurTimeEl:i,trackDurationEl:s,audioEl:o,waveformInst:l}=e;r&&(o&&(o.currentTime=0),l==null||l.seekTo(0)),n&&a&&(a.style.transform="scaleX(0)",n.style.transform="translateX(0px)"),i&&s&&(i.innerHTML="00:00",r||(s.innerHTML=t?Hn(t):"00:00"))},rf=(e,t)=>{var r,n,a,i;switch(t.type){case"NEXT_AUDIO":{if(e.curAudioState.repeatType==="NONE"&&e.curIdx+1===e.playList.length)return{...e,curAudioState:{...e.curAudioState,isPlaying:!1}};if(e.curAudioState.repeatType==="SHUFFLE"){let o=0;const l=()=>{o=Math.round(Math.random()*(e.playList.length-1))};for(;o===e.curIdx;)l();return{...e,curPlayId:e.playList[o].id,curIdx:o}}const s=(e.curIdx+1)%e.playList.length;return{...e,curIdx:s,curPlayId:e.playList[s].id}}case"PREV_AUDIO":{if(((r=e.elementRefs)==null?void 0:r.audioEl)&&((n=e.elementRefs)==null?void 0:n.audioEl.currentTime)>1||((a=e.elementRefs)==null?void 0:a.waveformInst)&&((i=e.elementRefs)==null?void 0:i.waveformInst.getCurrentTime())>1||e.curAudioState.repeatType==="NONE"&&e.curIdx===0)return Fn(e.elementRefs,void 0,!0),e;if(e.curAudioState.repeatType==="SHUFFLE"){const o=Math.round(Math.random()*(e.playList.length-1));return{...e,curPlayId:e.playList[o].id,curIdx:o}}const s=(e.curIdx-1+e.playList.length)%e.playList.length;return{...e,curPlayId:e.playList[s].id,curIdx:s}}case"UPDATE_PLAY_LIST":return t.playList.find(o=>o.id===e.curPlayId)?{...e,playList:t.playList,curIdx:e.curIdx}:(console.error("UPDATE_PLAY_LIST ERROR - curPlayId is not found on playList"),e);case"SET_VOLUME":return{...e,curAudioState:{...e.curAudioState,volume:t.volume}};case"SET_INITIAL_AUDIO_STATE":return{...e,curAudioState:{...e.curAudioState,...t.audioInitialState},curPlayId:t.audioInitialState.curPlayId};case"SET_PlAY_STATE":return t.state!==void 0?{...e,curAudioState:{...e.curAudioState,isPlaying:t.state}}:{...e,curAudioState:{...e.curAudioState,isPlaying:!e.curAudioState.isPlaying}};case"SET_CURRENT_AUDIO":return{...e,curPlayId:t.currentAudioId,curIdx:t.currentIndex};case"SET_REPEAT_TYPE":return{...e,curAudioState:{...e.curAudioState,repeatType:t.repeatType}};case"SET_PLACEMENTS":return{...e,playerPlacement:t.playerPlacement||e.playerPlacement,playListPlacement:t.playListPlacement||e.playListPlacement,interfacePlacement:t.interfacePlacement};case"SET_MUTED":return{...e,curAudioState:{...e.curAudioState,muted:t.muted}};case"SET_ACTIVE_UI":return{...e,activeUI:{...t.activeUI}};case"SET_ELEMENT_REFS":return{...e,elementRefs:{...e.elementRefs,...t.elementRefs}};case"SET_CUSTOM_ICONS":return{...e,customIcons:{...e.customIcons,...t.customIcons}};case"SET_COVER_IMGS_CSS":return{...e,coverImgsCss:{...e.coverImgsCss,...t.coverImgsCss}};default:throw new Error("Unhandled action")}},nf=({children:e})=>{const[t,r]=x.useReducer(rf,{playList:[],curPlayId:1,curIdx:0,curAudioState:{isPlaying:!1,repeatType:"ALL",volume:1},activeUI:{playButton:!0,volumeSlider:!0},playListPlacement:"bottom",interfacePlacement:{templateArea:{playButton:pe.templateArea.playButton}}});return L(Z.Provider,{value:t,children:L(ce.Provider,{value:r,children:e})})};const af=be.createGlobalStyle`
11
+ */var Yc=W.default,qc=Symbol.for("react.element"),Jc=Symbol.for("react.fragment"),Qc=Object.prototype.hasOwnProperty,Zc=Yc.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ef={key:!0,ref:!0,__self:!0,__source:!0};function Po(e,t,r){var n,a={},i=null,s=null;r!==void 0&&(i=""+r),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)Qc.call(t,n)&&!ef.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)a[n]===void 0&&(a[n]=t[n]);return{$$typeof:qc,type:e,key:i,ref:s,props:a,_owner:Zc.current}}sr.Fragment=Jc;sr.jsx=Po;sr.jsxs=Po;or.exports=sr;const L=or.exports.jsx,le=or.exports.jsxs,ze=or.exports.Fragment,tf=({children:e,rootContainerProps:t})=>{const{playerPlacement:r}=j(Z),[n,a]=x.useState();return x.useLayoutEffect(()=>{r&&a((()=>{switch(r){case"bottom":return{bottom:0};case"top":return{top:0};case"bottom-left":return{bottom:0,left:0};case"bottom-right":return{bottom:0,right:0};case"top-left":return{top:0,left:0};case"top-right":return{top:0,right:0}}})())},[r]),L(yo,{theme:Xc,width:"100%",position:r&&"fixed",UNSAFE_className:"rm-audio-player-provider",...n,...t,children:e})},ce=x.createContext(null),Hn=e=>{const t=`${Math.floor(e/60)}`.padStart(2,"0"),r=`${Math.floor(e%60)}`.padStart(2,"0");return`${t}:${r}`},Fn=(e,t,r)=>{if(!e)return;const{progressHandleEl:n,progressValueEl:a,trackCurTimeEl:i,trackDurationEl:s,audioEl:o,waveformInst:l}=e;r&&(o&&(o.currentTime=0),l==null||l.seekTo(0)),n&&a&&(a.style.transform="scaleX(0)",n.style.transform="translateX(0px)"),i&&s&&(i.innerHTML="00:00",r||(s.innerHTML=t?Hn(t):"00:00"))},rf=(e,t)=>{var r,n,a,i;switch(t.type){case"NEXT_AUDIO":{if(e.curAudioState.repeatType==="NONE"&&e.curIdx+1===e.playList.length)return{...e,curAudioState:{...e.curAudioState,isPlaying:!1}};if(e.curAudioState.repeatType==="SHUFFLE"){let o=0;const l=()=>{o=Math.round(Math.random()*(e.playList.length-1))};for(;o===e.curIdx;)l();return{...e,curPlayId:e.playList[o].id,curIdx:o}}const s=(e.curIdx+1)%e.playList.length;return{...e,curIdx:s,curPlayId:e.playList[s].id}}case"PREV_AUDIO":{if(((r=e.elementRefs)==null?void 0:r.audioEl)&&((n=e.elementRefs)==null?void 0:n.audioEl.currentTime)>1||((a=e.elementRefs)==null?void 0:a.waveformInst)&&((i=e.elementRefs)==null?void 0:i.waveformInst.getCurrentTime())>1||e.curAudioState.repeatType==="NONE"&&e.curIdx===0)return Fn(e.elementRefs,void 0,!0),e;if(e.curAudioState.repeatType==="SHUFFLE"){const o=Math.round(Math.random()*(e.playList.length-1));return{...e,curPlayId:e.playList[o].id,curIdx:o}}const s=(e.curIdx-1+e.playList.length)%e.playList.length;return{...e,curPlayId:e.playList[s].id,curIdx:s}}case"UPDATE_PLAY_LIST":{if(!t.playList.find(l=>l.id===e.curPlayId))return console.error("UPDATE_PLAY_LIST ERROR - curPlayId is not found on playList"),e;const o=t.playList.findIndex(l=>l.id===e.curPlayId);return{...e,playList:t.playList,curIdx:o}}case"SET_VOLUME":return{...e,curAudioState:{...e.curAudioState,volume:t.volume}};case"SET_INITIAL_AUDIO_STATE":return{...e,curAudioState:{...e.curAudioState,...t.audioInitialState},curPlayId:t.audioInitialState.curPlayId};case"SET_PlAY_STATE":return t.state!==void 0?{...e,curAudioState:{...e.curAudioState,isPlaying:t.state}}:{...e,curAudioState:{...e.curAudioState,isPlaying:!e.curAudioState.isPlaying}};case"SET_CURRENT_AUDIO":return{...e,curPlayId:t.currentAudioId,curIdx:t.currentIndex};case"SET_REPEAT_TYPE":return{...e,curAudioState:{...e.curAudioState,repeatType:t.repeatType}};case"SET_PLACEMENTS":return{...e,playerPlacement:t.playerPlacement||e.playerPlacement,playListPlacement:t.playListPlacement||e.playListPlacement,interfacePlacement:t.interfacePlacement};case"SET_MUTED":return{...e,curAudioState:{...e.curAudioState,muted:t.muted}};case"SET_ACTIVE_UI":return{...e,activeUI:{...t.activeUI}};case"SET_ELEMENT_REFS":return{...e,elementRefs:{...e.elementRefs,...t.elementRefs}};case"SET_CUSTOM_ICONS":return{...e,customIcons:{...e.customIcons,...t.customIcons}};case"SET_COVER_IMGS_CSS":return{...e,coverImgsCss:{...e.coverImgsCss,...t.coverImgsCss}};default:throw new Error("Unhandled action")}},nf=({children:e})=>{const[t,r]=x.useReducer(rf,{playList:[],curPlayId:1,curIdx:0,curAudioState:{isPlaying:!1,repeatType:"ALL",volume:1},activeUI:{playButton:!0,volumeSlider:!0},playListPlacement:"bottom",interfacePlacement:{templateArea:{playButton:pe.templateArea.playButton}}});return L(Z.Provider,{value:t,children:L(ce.Provider,{value:r,children:e})})};const af=be.createGlobalStyle`
12
12
 
13
13
  .rm-audio-player-provider {
14
14
  * {
package/dist/index.es.js CHANGED
@@ -8119,10 +8119,11 @@ const audioPlayerReducer = (state, action) => {
8119
8119
  console.error("UPDATE_PLAY_LIST ERROR - curPlayId is not found on playList");
8120
8120
  return state;
8121
8121
  }
8122
+ const curIdx = action.playList.findIndex((item) => item.id === state.curPlayId);
8122
8123
  return {
8123
8124
  ...state,
8124
8125
  playList: action.playList,
8125
- curIdx: state.curIdx
8126
+ curIdx
8126
8127
  };
8127
8128
  }
8128
8129
  case "SET_VOLUME":
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "react-modern-audio-player",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
+ "author": {
5
+ "name": "LYH",
6
+ "email": "slash9494@naver.com",
7
+ "url": "https://github.com/slash9494"
8
+ },
4
9
  "homepage": "https://github.com/slash9494/react-modern-audio-player/",
5
10
  "module": "dist/index.es.js",
6
11
  "main": "dist/index.cjs",
@@ -9,6 +14,7 @@
9
14
  "files": [
10
15
  "dist"
11
16
  ],
17
+ "license": "MIT",
12
18
  "repository": {
13
19
  "type": "git",
14
20
  "url": "git+https://github.com/slash9494/react-modern-audio-player.git"