mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
audio: NewPlayerFromBytes now never returns errors
This commit is contained in:
parent
9a4a7fe5ba
commit
98c48463d2
@ -350,10 +350,15 @@ func NewPlayer(context *Context, src ReadSeekCloser) (*Player, error) {
|
||||
//
|
||||
// The format of src should be same as noted at NewPlayer.
|
||||
//
|
||||
// NewPlayerFromBytes returns error in the same situation of NewPlayer.
|
||||
// NewPlayerFromBytes's error is always nil as of 1.5.0-alpha.
|
||||
func NewPlayerFromBytes(context *Context, src []byte) (*Player, error) {
|
||||
b := BytesReadSeekCloser(src)
|
||||
return NewPlayer(context, b)
|
||||
p, err := NewPlayer(context, b)
|
||||
if err != nil {
|
||||
// Errors should never happen.
|
||||
panic(err)
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// Close closes the stream. Ths source stream passed by NewPlayer will also be closed.
|
||||
|
@ -88,7 +88,8 @@ func (p *Player) updateSE() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return sePlayer.Play()
|
||||
sePlayer.Play()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Player) updateVolume() {
|
||||
|
@ -87,10 +87,7 @@ func addNote(freq float64, vol float64) error {
|
||||
// collects a *audio.Player object.
|
||||
f := int(freq)
|
||||
if n, ok := noteCache[f]; ok {
|
||||
p, err := audio.NewPlayerFromBytes(audioContext, n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p, _ := audio.NewPlayerFromBytes(audioContext, n)
|
||||
if err := p.Play(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -110,10 +107,7 @@ func addNote(freq float64, vol float64) error {
|
||||
}
|
||||
n := toBytes(l, r)
|
||||
noteCache[f] = n
|
||||
p, err := audio.NewPlayerFromBytes(audioContext, n)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p, _ := audio.NewPlayerFromBytes(audioContext, n)
|
||||
if err := p.Play(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user