Skip to content

Commit

Permalink
fix: cannot toggle mode on Android device #163
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 committed Sep 27, 2020
1 parent 19270ae commit 25120c3
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 203 deletions.
3 changes: 1 addition & 2 deletions example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,10 @@ const options = {
bottom: 120,
},

defaultPlayMode: 'order',

// if you want dynamic change current play mode you can change it
// [type`order | orderLoop | singleLoop | shufflePlay`, default `order`]
// playMode: 'order',
defaultPlayMode: 'order',

// audio mode mini | full [type `String` default `mini`]
mode: 'full',
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"downloadjs": "^1.4.7",
"is-mobile": "^2.2.2",
"prop-types": "^15.7.2",
"rc-slider": "^9.3.1",
"rc-slider": "^9.5.1",
"rc-switch": "^3.2.1",
"react-drag-listview": "^0.1.7",
"react-draggable": "^4.4.3",
Expand Down Expand Up @@ -116,7 +116,7 @@
"@types/jest": "^26.0.14",
"@types/react": "^16.9.49",
"@types/react-dom": "^16.9.8",
"autoprefixer": "^10.0.0",
"autoprefixer": "^10.0.1",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.3.0",
Expand All @@ -132,21 +132,21 @@
"cross-env": "^7.0.2",
"css-loader": "^4.3.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.4",
"enzyme-to-json": "^3.5.0",
"enzyme-adapter-react-16": "^1.15.5",
"enzyme-to-json": "^3.6.0",
"esbuild-webpack-plugin": "^1.0.5",
"eslint": "^7.9.0",
"eslint": "^7.10.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-prettier": "^6.12.0",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react": "^7.21.2",
"extract-text-webpack-plugin": "4.0.0-beta.0",
"file-loader": "^6.1.0",
"html-loader": "^1.3.0",
"html-webpack-plugin": "^4.4.1",
"html-loader": "^1.3.1",
"html-webpack-plugin": "^4.5.0",
"husky": "^4.3.0",
"jest": "^26.4.2",
"jest-environment-jsdom": "^26.3.0",
Expand All @@ -157,15 +157,15 @@
"mini-css-extract-plugin": "^0.11.2",
"open-browser-webpack-plugin": "0.0.5",
"optimize-css-assets-webpack-plugin": "^5.0.4",
"postcss": "^8.0.5",
"postcss-cli": "^7.1.2",
"postcss": "^8.1.0",
"postcss-cli": "^8.0.0",
"postcss-loader": "^4.0.2",
"power-assert": "^1.6.1",
"pre-commit": "^1.2.2",
"prettier": "^2.1.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-hot-loader": "^4.12.21",
"react-hot-loader": "^4.13.0",
"react-loader": "^2.4.7",
"rimraf": "^3.0.2",
"semantic-release": "^17.1.2",
Expand Down
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -959,12 +959,19 @@ export default class ReactJkMusicPlayer extends PureComponent {
}
}

onControllerDrag = () => {
onControllerDrag = (e, { x, y }) => {
const { moveX, moveY } = this.state
this.isDrag = true

// mousedown will trigger drag event on android devices (react-draggable) :(
if (moveX === x && moveY === y) {
this.isDrag = false
}
}

onControllerDragStart = () => {
onControllerDragStart = (e, { x, y }) => {
this.isDrag = false
this.setState({ moveX: x, moveY: y })
}

onControllerDragStop = (e, { x, y }) => {
Expand All @@ -977,6 +984,7 @@ export default class ReactJkMusicPlayer extends PureComponent {
this.onDestroyPlayer()
return
}

if (!this.isDrag) {
if (this.state.isNeedMobileHack) {
this.loadAndPlayAudio()
Expand Down

0 comments on commit 25120c3

Please sign in to comment.