Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clearPriorAudioLists #115

Closed
steveambielli opened this issue May 27, 2020 · 4 comments
Closed

clearPriorAudioLists #115

steveambielli opened this issue May 27, 2020 · 4 comments

Comments

@steveambielli
Copy link

steveambielli commented May 27, 2020

Version

4.13.1

Description

When setting the boolean to true and updating the audioLists via setState, I get this error:

TypeError: Cannot read property 'id' of undefined
ReactJkMusicPlayer.getPlayId
C:/[PATH]/node_modules/react-jinke-music-player/es/index.js:1052

  1049 | _defineProperty(_assertThisInitialized(_this), "getPlayId", function () {
  1050 |   var audioLists = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.state.audioLists;
  1051 |   var playIndex = Math.max(0, Math.min(audioLists.length, _this.props.defaultPlayIndex));
  1052 |   var playId = _this.state.playId || audioLists[playIndex].id;
       | ^  1053 |   return playId;
  1054 | });
  1055 | 

Expected Behavior

The audioList should be cleared out and the new state should be loaded.

@lijinke666
Copy link
Owner

Can you show your code ? your audioLists is empty array after updated?

console.log(your audio lists)

@steveambielli
Copy link
Author

steveambielli commented May 28, 2020

When the app loads the playlist state is empty:

this.state { playlist: '' }

In componentDidMount() it calls the function this.getPlaylist() and passes a variable for the playlist to fetch which changes the state of playlist. This is where the error is thrown and this morning it's throwing two errors.

TypeError: Cannot read property 'id' of undefined

1049 | _defineProperty(_assertThisInitialized(_this), "getPlayId", function () { 1050 | var audioLists = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.state.audioLists; 1051 | var playIndex = Math.max(0, Math.min(audioLists.length, _this.props.defaultPlayIndex)); 1052 | var playId = _this.state.playId || audioLists[playIndex].id; 1053 | return playId; 1054 | });

and

`
TypeError: Cannot read property 'stop' of undefined
1951 | this.unBindKeyDownEvents();
1952 | this.media.removeListener(this.listenerIsMobile);
1953 | this.media = undefined;

1954 | this.lyric.stop();
| ^ 1955 | }
1956 | }, {
1957 | key: "componentDidMount",
`

@lijinke666
Copy link
Owner

TypeError: Cannot read property 'stop' of undefined

https://github.com/lijinke666/react-music-player/blob/master/src/index.js#L1923

beasuse player only init when playlist not empty in componentDidMount, so this.lyric not be init. it's a bug. i will to fix it. sry.

TypeError: Cannot read property 'id' of undefined

please upgrade latest version 4.14.0, i think the issue is fixed.

it's a temporary solution

- this.state = { playlist: '' }
+ this.state = { playlist: [{}] }

thank your feedback.

lijinke666 added a commit that referenced this issue May 29, 2020
@lijinke666
Copy link
Owner

fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants