[Python] How to catch exception from VLC?

Discussão em 'Python' iniciado por Stack, Março 16, 2025.

  1. Stack

    Stack Membro Participativo

    I have problem with catching exception from VLC. Instead of printing my text I get information like:

    • [00007f0988001690] filesystem stream error: cannot open file /home/user/recording.mp3 (No such file or directory)
    • [0000557838609be0] main input error: Your input can't be opened
    • [0000557838609be0] main input error: VLC is unable to open the MRL 'file:///home/user/recording.mp3'. Check the log for details.

    Here is my code:

    from vlc import MediaPlayer

    x = MediaPlayer('recording.mp3')

    def play_sound():
    try:
    x.play()
    except:
    print('Cannot play sound.')

    play_sound()


    How to fix it?

    Continue reading...

Compartilhe esta Página