Skip to content

[BUG] Simple Play example doesn't quit after playing finishes #200

@digfish

Description

@digfish

Describe the bug
Hi, I tried your library using a simple example

To Reproduce
Steps to reproduce the behavior:
On VS Code 1.78.2 i run The following snippet:

    zeroconf = ZeroconfServer.Builder().create()
    session = Session.Builder() \
        .user_pass("myusername", "mypassword") \
        .create()
    access_token = session.tokens().get("playlist-read")
    track_id = TrackId.from_uri("spotify:track:6UCFZ9ZOFRxK8oak7MdPZu")
    stream = session.content_feeder().load(track_id, VorbisOnlyAudioQuality(AudioQuality.VERY_HIGH), False, None)

    ffplay = subprocess.Popen(
        ["ffplay", "-autoexit", "-"],
        stdin=subprocess.PIPE,
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL,
    )

    ended = False
    while ended !=True:
        if ended : print("ended")
        bytes = stream.input_stream.stream().read(256)
        sent = ffplay.stdin.write(bytes)
        if sent == 0:
            logging.info("0 bytes sent!")
            ended = True

Expected behavior
FFplay pops out and starts playing the track until the end after that exits cleanly but the program is stuck. I'm only able to stop pressing the trash button to kill terminal pane on vscode or killing it manually in the task manager. Doesn't respond to Ctrl+C

Screenshots
Last lines of output:

DEBUG:Librespot:Session:Chunk 8/8 completed, cached: False, stream: file_id: 6dba450723dfdf967aa3740beeca4d73adde7bca
INFO:root:0 bytes sent!

Client Information (please complete the following information):

  • OS: Windows 10 22H2
  • Python Version miniconda v 3.10.4
  • Library Version 0.0.9

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions