Issue when player recreated
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
When I use it for the first time, all works great. But when I recreate player, next issue happen :
```
APlayer.min.js?46f1:1 Uncaught TypeError: Cannot read property 'classList' of undefined
at e.value (APlayer.min.js?46f1:1)
at e.value (APlayer.min.js?46f1:1)
at eval (APlayer.min.js?46f1:1)
```
```
import * as APlayer from 'aplayer/dist/APlayer.min'
import 'aplayer/dist/APlayer.min'
...
fetch (path) {
let _those = this
api.fetch(path)
.then(function (req) {
for (let i in req.items) {
let item = req.items[i]
if (item.isDir) {
// Do recursive here
_those.fetch(item.url)
} else if (item.type == 'audio') {
_those.player.list.add({
name: item.name,
url: url.convertToDownload(item.url)
})
}
}
if (_those.player.audio.paused && _those.player.list.audios.length > 0) {
_those.player.list.show()
_those.player.setMode('normal')
_those.player.play()
}
}).catch(this.$showError)
},
resetPlayer (isFixed) {
if (this.player) {
this.player.list.clear()
this.player.pause()
this.player.destroy()
}
this.player = new APlayer({
element: document.getElementById('player'),
fixed: isFixed,
mini: isFixed,
lrcType: 3
})
}
....
let _those = this
playerEventBus.$on('playTrack', function (track) {
_those.resetPlayer(true)
_those.player.list.add(track)
_those.player.play()
})
playerEventBus.$on('playFolders', function (paths) {
_those.resetPlayer(false)
for (let p in paths) {
_those.fetch(paths[p])
}
})
}
```
The reason I tried to recreate it, are switch between small/big/fixed
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.