mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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.
|
// 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) {
|
func NewPlayerFromBytes(context *Context, src []byte) (*Player, error) {
|
||||||
b := BytesReadSeekCloser(src)
|
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.
|
// 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return sePlayer.Play()
|
sePlayer.Play()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) updateVolume() {
|
func (p *Player) updateVolume() {
|
||||||
|
@ -87,10 +87,7 @@ func addNote(freq float64, vol float64) error {
|
|||||||
// collects a *audio.Player object.
|
// collects a *audio.Player object.
|
||||||
f := int(freq)
|
f := int(freq)
|
||||||
if n, ok := noteCache[f]; ok {
|
if n, ok := noteCache[f]; ok {
|
||||||
p, err := audio.NewPlayerFromBytes(audioContext, n)
|
p, _ := audio.NewPlayerFromBytes(audioContext, n)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := p.Play(); err != nil {
|
if err := p.Play(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -110,10 +107,7 @@ func addNote(freq float64, vol float64) error {
|
|||||||
}
|
}
|
||||||
n := toBytes(l, r)
|
n := toBytes(l, r)
|
||||||
noteCache[f] = n
|
noteCache[f] = n
|
||||||
p, err := audio.NewPlayerFromBytes(audioContext, n)
|
p, _ := audio.NewPlayerFromBytes(audioContext, n)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := p.Play(); err != nil {
|
if err := p.Play(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user