mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
audio: Bug fix: Need to call setReady from the reader player side
Updates #1599
This commit is contained in:
parent
b1545b115c
commit
ea9d64f5b8
@ -25,6 +25,6 @@ func IsAvailable() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContext(sampleRate int, channelNum int, bitDepthInBytes int) (Context, error) {
|
func NewContext(sampleRate int, channelNum int, bitDepthInBytes int, onReady func()) (Context, error) {
|
||||||
panic(fmt.Sprintf("readerdriver: NewContext is not available on this environment: GOOS=%s", runtime.GOOS))
|
panic(fmt.Sprintf("readerdriver: NewContext is not available on this environment: GOOS=%s", runtime.GOOS))
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ type contextImpl struct {
|
|||||||
bitDepthInBytes int
|
bitDepthInBytes int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContext(sampleRate int, channelNum int, bitDepthInBytes int) (Context, error) {
|
func NewContext(sampleRate int, channelNum int, bitDepthInBytes int, onReady func()) (Context, error) {
|
||||||
if js.Global().Get("go2cpp").Truthy() {
|
if js.Global().Get("go2cpp").Truthy() {
|
||||||
return &go2cppDriverWrapper{go2cpp.NewContext(sampleRate, channelNum, bitDepthInBytes)}, nil
|
return &go2cppDriverWrapper{go2cpp.NewContext(sampleRate, channelNum, bitDepthInBytes)}, nil
|
||||||
}
|
}
|
||||||
@ -68,6 +68,7 @@ func NewContext(sampleRate int, channelNum int, bitDepthInBytes int) (Context, e
|
|||||||
if !d.ready {
|
if !d.ready {
|
||||||
d.audioContext.Call("resume")
|
d.audioContext.Call("resume")
|
||||||
d.ready = true
|
d.ready = true
|
||||||
|
onReady()
|
||||||
}
|
}
|
||||||
js.Global().Get("document").Call("removeEventListener", event, f)
|
js.Global().Get("document").Call("removeEventListener", event, f)
|
||||||
return nil
|
return nil
|
||||||
|
@ -68,7 +68,9 @@ func (p *readerPlayer) ensurePlayer() error {
|
|||||||
// is unexpectable.
|
// is unexpectable.
|
||||||
// e.g. a variable for JVM on Android might not be set.
|
// e.g. a variable for JVM on Android might not be set.
|
||||||
if p.factory.context == nil {
|
if p.factory.context == nil {
|
||||||
c, err := readerdriver.NewContext(p.factory.sampleRate, channelNum, bitDepthInBytes)
|
c, err := readerdriver.NewContext(p.factory.sampleRate, channelNum, bitDepthInBytes, func() {
|
||||||
|
p.context.setReady()
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user