diff --git a/audio/player.go b/audio/player.go index 976288b05..37ab868f6 100644 --- a/audio/player.go +++ b/audio/player.go @@ -408,7 +408,9 @@ func newTimeStream(r io.Reader, seekable bool, sampleRate int, bitDepthInBytes i // Get the current position of the source. pos, err := s.r.(io.Seeker).Seek(0, io.SeekCurrent) if err != nil { - return nil, err + // Ignore the error, as the undelrying source might not support Seek (#3192). + // This happens when vorbis.Decode* is used, as vorbis.Stream is io.Seeker whichever the underlying source is. + pos = 0 } s.pos.Store(pos) } diff --git a/audio/vorbis/vorbis_test.go b/audio/vorbis/vorbis_test.go index e9f5e7327..76e395e13 100644 --- a/audio/vorbis/vorbis_test.go +++ b/audio/vorbis/vorbis_test.go @@ -137,6 +137,8 @@ func TestNonSeeker(t *testing.T) { if got, want := s.SampleRate(), audioContext.SampleRate(); got != want { t.Errorf("s.SampleRate(): got: %d, want: %d", got, want) } + + // TODO: Check the result of io.ReadAll (#3192). } func TestNonSeekerF32(t *testing.T) { @@ -150,4 +152,12 @@ func TestNonSeekerF32(t *testing.T) { if got, want := s.Length(), int64(0); got != want { t.Errorf("s.Length(): got: %d, want: %d", got, want) } + + buf, err := io.ReadAll(s) + if err != nil { + t.Errorf("io.ReadAll: %v", err) + } + if len(buf) == 0 { + t.Errorf("len(buf): got: %d, want: > 0", len(buf)) + } }