fixed: player duration error Infinity:NaN #24
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
为了修复这个 bug,添加了一个新的 State,考量如下:
原先 PlayerState 就是一个独立的 State,但是由于 HTTPAudioElement 中的 duration 在流媒体播放时总是 Infinity(除了最后三秒外)
这个 duration 应该和 PlayerState 有同等地位(绑在一起了),但是考虑到原有的代码可能需要直接调用它,所以并没有将其直接并入 PlayerState,而是另外加了个 PlayerDurationState
当然最主要原因是,直接弄一个回调函数给 usePlayer 是没有用的,因为这个 duration 只在调用 play() 的时候更新,但是此时 usePlayerTime 并不会执行 play(),想不到其他办法了
这个问题解决后,anniw 的进度条也能拖动了