From df40217427677f6dc4153673f7bacc07faf66d2f Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 9 May 2021 23:09:15 +0900 Subject: [PATCH] audio/internal/readerdriver: Skip operation on error (js) --- audio/internal/readerdriver/driver_js.go | 27 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/audio/internal/readerdriver/driver_js.go b/audio/internal/readerdriver/driver_js.go index e6ce34d30..27e1a6cbd 100644 --- a/audio/internal/readerdriver/driver_js.go +++ b/audio/internal/readerdriver/driver_js.go @@ -126,7 +126,22 @@ func (c *context) Resume() error { return nil } +func (p *player) Play() { + if p.err != nil { + return + } + if p.state != playerPaused { + return + } + p.state = playerPlay + p.appendBuffer(js.Undefined(), nil) + p.appendBuffer(js.Undefined(), nil) +} + func (p *player) Pause() { + if p.err != nil { + return + } if p.state != playerPlay { return } @@ -232,20 +247,14 @@ func (p *player) appendBuffer(this js.Value, args []js.Value) interface{} { return nil } -func (p *player) Play() { - if p.state != playerPaused { - return - } - p.state = playerPlay - p.appendBuffer(js.Undefined(), nil) - p.appendBuffer(js.Undefined(), nil) -} - func (p *player) IsPlaying() bool { return p.state == playerPlay } func (p *player) Reset() { + if p.err != nil { + return + } if p.state == playerClosed { return }