2

I want to make mediaplayer, I choosed python-vlc library, but I don't know why I can't play audio/video from .py file. If I tried make it with cmd and Python Shell all working:

>>> import vlc
>>> my_player = vlc.MediaPlayer("d:/Music/song.flac")
>>> my_player.play()
0

I write same in .py file:

import vlc

my_player = vlc.MediaPlayer("d:/Music/song.flac")
my_player.play()

When I start it in cmd and PyCharm nothing happens and I don't receive any errors, but when I start debuging I receive this:

[04521730] mmdevice audio output error: cannot initialize COM (error 0x80010106)
[04545aa0] mmdevice audio output error: cannot initialize COM (error 0x80010106)

P.S. I use Python 3.8.0 (32 bit) and I have installed VLC player (32 bit) on Windows 10.

Thanks in advance!

1 Answer 1

1

After some research, you need to add a infinite loop or the delay while you want your song on.

For example if you want 10s of music :

import vlc
import time

p = vlc.MediaPlayer(r"C:\Users\username\Downloads\test.mp3")
p.play()

time.sleep(10)

or

import vlc

p = vlc.MediaPlayer(r"C:\Users\username\Downloads\test.mp3")
p.play()

while True:
     pass
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.