Skip to content

Commit 8aad39f

Browse files
committed
fixme: beep FLAC格式(其他未测)跳转卡顿
1 parent 6784362 commit 8aad39f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pkg/player/beep_player.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ func (p *beepPlayer) listen() {
114114
go func(ctx context.Context, cacheWFile *os.File, read io.ReadCloser) {
115115
defer utils.Recover(false)
116116
_, _ = utils.CopyClose(ctx, cacheWFile, read)
117-
p.curStreamer, p.curFormat, _ = DecodeSong(p.curMusic.Type, p.cacheReader)
117+
// 除了MP3格式,其他格式无需重载
118+
if p.curMusic.Type == Mp3 {
119+
if p.curStreamer, p.curFormat, err = DecodeSong(p.curMusic.Type, p.cacheReader); err != nil {
120+
p.Stop()
121+
}
122+
}
123+
118124
}(ctx, p.cacheWriter, resp.Body)
119125

120126
if err = utils.WaitForNBytes(p.cacheReader, 512, time.Millisecond*100, 50); err != nil {
@@ -197,6 +203,12 @@ func (p *beepPlayer) TimeChan() <-chan time.Duration {
197203
}
198204

199205
func (p *beepPlayer) Seek(duration time.Duration) {
206+
// FIXME: 暂时仅对MP3格式提供跳转功能
207+
// FLAC格式(其他未测)跳转会占用大量CPU资源,比特率越高占用越高
208+
// 导致Seek方法卡住20-40秒的时间,之后方可随意跳转
209+
if p.curMusic.Type != Mp3 {
210+
return
211+
}
200212
if p.state == Playing || p.state == Paused {
201213

202214
speaker.Lock()

0 commit comments

Comments
 (0)