oaubert / python-vlc

Python vlc bindings
GNU Lesser General Public License v2.1
388 stars 111 forks source link

Problem with Audio Visualization #214

Open Raj-Kumar-Mishra opened 2 years ago

Raj-Kumar-Mishra commented 2 years ago

Hi, I want audio visualization in my project using python-vlc. i came to know this command line argument --audio-visual=goom and passed through vlc.Instance() constructor parameter. It successfully shows the visualization effect. e.g. Screenshot (187)

But the problem arises when i switch music to a video file.It opens another window along with video playing. e.g Screenshot (186)

Here is my minimal code

from PyQt5.QtWidgets import *

mediafiles=["abcd.mp3",abcd1 .mp4"]

class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(500,500)
        self.index=0
        b=QPushButton("Change Media",self)
        b.setGeometry(100,10,300,35)
        b.clicked.connect(self.change)
        self.videoframe=QFrame(self)
        self.videoframe.setGeometry(0,50,500,450)
        self.instance=vlc.Instance("--audio-visual=goom")
        self.player=self.instance.media_player_new()
        self.player.set_hwnd(self.videoframe.winId())
        self.player.set_media(self.instance.media_new(mediafiles[self.index]))
        self.player.play()
    def change(self)  :
        self.index+=1
        if self.index==2:
            self.index=0
        self.player.set_media(self.instance.media_new(mediafiles[self.index]))
        self.player.play()    

app = QApplication([])
window = Window()
window.show()
sys.exit(app.exec_())

Can anybody help me how to fix this?