diff --git a/audio/audio.go b/audio/audio.go index 6554adf0b..a6dac5e53 100644 --- a/audio/audio.go +++ b/audio/audio.go @@ -201,7 +201,7 @@ func (c *Context) IsReady() bool { // problematic when a user tries to play audio after the context is ready. // Play a dummy player to avoid the blocking (#969). // Use a long enough buffer so that writing doesn't finish immediately (#970). - p, _ := NewPlayerFromBytes(c, make([]byte, bufferSize()*2)) + p := NewPlayerFromBytes(c, make([]byte, bufferSize()*2)) p.Play() }() @@ -309,16 +309,14 @@ func NewPlayer(context *Context, src io.ReadCloser) (*Player, error) { // src can be shared by multiple players. // // The format of src should be same as noted at NewPlayer. -// -// NewPlayerFromBytes's error is always nil as of 1.5.0-alpha. -func NewPlayerFromBytes(context *Context, src []byte) (*Player, error) { +func NewPlayerFromBytes(context *Context, src []byte) *Player { b := BytesReadSeekCloser(src) p, err := NewPlayer(context, b) if err != nil { // Errors should never happen. panic(fmt.Sprintf("audio: %v at NewPlayerFromBytes", err)) } - return p, nil + return p } func (p *Player) finalize() { diff --git a/examples/audio/main.go b/examples/audio/main.go index f99aeca32..b2c96a7f1 100644 --- a/examples/audio/main.go +++ b/examples/audio/main.go @@ -179,7 +179,7 @@ func (p *Player) playSEIfNeeded() { if !inpututil.IsKeyJustPressed(ebiten.KeyP) { return } - sePlayer, _ := audio.NewPlayerFromBytes(p.audioContext, p.seBytes) + sePlayer := audio.NewPlayerFromBytes(p.audioContext, p.seBytes) sePlayer.Play() } diff --git a/examples/pcm/main.go b/examples/pcm/main.go index dbbd20109..8a9ff14a5 100644 --- a/examples/pcm/main.go +++ b/examples/pcm/main.go @@ -125,7 +125,7 @@ func playNote(scoreIndex int) rune { square(l, vol, freq, 0.25) square(r, vol, freq, 0.25) - p, _ := audio.NewPlayerFromBytes(audioContext, toBytes(l, r)) + p := audio.NewPlayerFromBytes(audioContext, toBytes(l, r)) p.Play() return rune(note) diff --git a/examples/piano/main.go b/examples/piano/main.go index f2a263b3e..16dfc013f 100644 --- a/examples/piano/main.go +++ b/examples/piano/main.go @@ -147,7 +147,7 @@ func init() { // playNote plays piano sound with the given frequency. func playNote(freq float64) { f := int(freq) - p, _ := audio.NewPlayerFromBytes(audioContext, pianoNoteSamples[f]) + p := audio.NewPlayerFromBytes(audioContext, pianoNoteSamples[f]) p.Play() }