Skip to content

audiomp3 only accepts io.FileIO objects, documentation suggests it could take io.BytesIO object as well #6850

Open
@studiostephe

Description

@studiostephe

CircuitPython version

CircuitPython 7.3.3; Adafruit KB2040 with rp2040

Code/REPL

mp3 = io.BytesIO(my_mp3_as_bytes)
decoder = MP3Decoder(mp3)

Behavior

TypeError: file must be a file opened in byte mode

Description

I read a small (32kb) mp3 file into memory as bytes, from serial. Currently I must write those bytes to a file on the filesystem and then reopen it, because MP3Decoder only accepts FileIO objects. It would be useful to be able to give a BytesIO object to MP3Decoder, especially since the objects are functionally very similar.

Additional information

The source line in question: https://github.com/adafruit/circuitpython/blob/main/shared-bindings/audiomp3/MP3Decoder.c#L96

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions