Robert Baker
Robert Baker

Reputation: 267

python3 vlc module - no audio

I am running python3 with the vlc module version python-vlc==3.0.4106.

When I run the following python3 script I get no audio:

import vlc

p = vlc.MediaPlayer("/path/to/music.mp3")
p.play()

When I run that script I get no output, no errors, no audio.

When I play the mp3 on the command line using cvlc is plays fine.

Anyone knows what I am doing wrong?

Upvotes: 1

Views: 2456

Answers (2)

Robert Baker
Robert Baker

Reputation: 267

The issue is that the program is terminating before it can even play the audio file. if you change the code to:

import time 
import vlc

p = vlc.MediaPlayer("file:///music.flac")
p.play()
time.sleep(10)

It works fine.

Upvotes: 2

Pramod
Pramod

Reputation: 161

If you ever use p.audio_set_volume(100) there is a chance of the player is muted so just set it back to 100.Use the following code...

import vlc,time
#Specifie your path for the song
p = vlc.MediaPlayer(r"C:\Users\dell5567\Desktop\engsong\Dire-Straits-Walk-Of-Life.mp3")
p.play()
#Sets the volume to 100
p.audio_set_volume(100)
time.sleep(10)

Upvotes: 1

Related Questions