python如何输出音轨至wxpython音量柱

用wxpython+python-vlc做好了一个嵌入式播放器,主要想用来做轮训工作,由于轮训内容会有音频,可是音频没画面所以需要音量柱来体现,目前主要想法是通过请求python-vlc获取当前音轨,并实时传到插件上,可是网上找了很多资料都没有涉及音轨返回的,而且感觉使用python-vlc的人非常少,希望了解python-vlc的朋友指点指点
# -*- coding: utf-8 -*- 

###########################################################################
## Python code generated with wxFormBuilder (version Jul 14 2018)
## http://www.wxformbuilder.org/
##
## PLEASE DO *NOT* EDIT THIS FILE!
###########################################################################

import wx
import wx.xrc
import vlc, requests, time, re, hashlib, queue


###########################################################################
## Class FrameMain
###########################################################################

class FrameMain(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, id=wx.ID_ANY, title=u"HLS-Inspection", pos=wx.DefaultPosition,
                          size=wx.Size(977, 459), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)

        self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)

        bSizerMain = wx.BoxSizer(wx.VERTICAL)

        self.m_panelMainPanel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL)
        bSizerPanel = wx.BoxSizer(wx.VERTICAL)

        bSizerPanelVideoMain = wx.BoxSizer(wx.HORIZONTAL)

        bSizerLeft = wx.BoxSizer(wx.HORIZONTAL)

        self.m_panelLeft = wx.Panel(self.m_panelMainPanel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
                                    wx.TAB_TRAVERSAL)
        self.m_panelLeft.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))

        bSizerLeft.Add(self.m_panelLeft, 1, wx.EXPAND | wx.ALL, 0)

        self.m_gaugeLeft = wx.Gauge(self.m_panelMainPanel, wx.ID_ANY, 100, wx.DefaultPosition, wx.Size(-1, 400),
                                    wx.GA_VERTICAL)
        self.m_gaugeLeft.SetValue(0)
        bSizerLeft.Add(self.m_gaugeLeft, 0, wx.ALL, 0)

        bSizerPanelVideoMain.Add(bSizerLeft, 1, wx.EXPAND, 0)

        bSizerRight = wx.BoxSizer(wx.HORIZONTAL)

        self.m_panelRight = wx.Panel(self.m_panelMainPanel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
                                     wx.TAB_TRAVERSAL)
        self.m_panelRight.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))

        bSizerRight.Add(self.m_panelRight, 1, wx.EXPAND | wx.ALL, 0)

        self.m_gaugeRight = wx.Gauge(self.m_panelMainPanel, wx.ID_ANY, 100, wx.DefaultPosition, wx.Size(-1, 400),
                                     wx.GA_HORIZONTAL | wx.GA_VERTICAL)
        self.m_gaugeRight.SetValue(0)
        bSizerRight.Add(self.m_gaugeRight, 0, wx.ALL, 0)

        bSizerPanelVideoMain.Add(bSizerRight, 1, wx.EXPAND, 0)

        bSizerPanel.Add(bSizerPanelVideoMain, 0, wx.ALL | wx.EXPAND, 0)

        self.m_staticline4 = wx.StaticLine(self.m_panelMainPanel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
                                           wx.LI_HORIZONTAL)
        bSizerPanel.Add(self.m_staticline4, 0, wx.EXPAND | wx.ALL, 1)

        bSizerbuttom = wx.BoxSizer(wx.HORIZONTAL)

        self.m_buttonStart = wx.Button(self.m_panelMainPanel, wx.ID_ANY, u"开始", wx.DefaultPosition, wx.DefaultSize, 0)
        bSizerbuttom.Add(self.m_buttonStart, 0, wx.ALL, 0)

        self.m_buttonStop = wx.Button(self.m_panelMainPanel, wx.ID_ANY, u"停止", wx.DefaultPosition, wx.DefaultSize, 0)
        bSizerbuttom.Add(self.m_buttonStop, 0, wx.ALL, 0)

        bSizerPanel.Add(bSizerbuttom, 0, wx.ALL | wx.EXPAND, 0)

        self.m_panelMainPanel.SetSizer(bSizerPanel)
        self.m_panelMainPanel.Layout()
        bSizerPanel.Fit(self.m_panelMainPanel)
        bSizerMain.Add(self.m_panelMainPanel, 1, wx.EXPAND | wx.ALL, 0)

        self.SetSizer(bSizerMain)
        self.Layout()
        self.timer = wx.Timer()
        self.timer.SetOwner(self, wx.ID_ANY)

        self.Centre(wx.BOTH)

        # Connect Events
        self.m_buttonStart.Bind(wx.EVT_BUTTON, self.m_buttonStartOnButtonClick)
        self.m_buttonStop.Bind(wx.EVT_BUTTON, self.m_buttonStopOnButtonClick)
        self.Bind(wx.EVT_TIMER, self.timerOnTimer, id=wx.ID_ANY)

        self.Instance = vlc.Instance()
        self.playerM = self.Instance.media_player_new()
        self.playerB = self.Instance.media_player_new()

    def __del__(self):
        pass

    # Virtual event handlers, overide them in your derived class
    def m_buttonStartOnButtonClick(self, event):
        self.vlc_play()
        # event.Skip()

    def m_buttonStopOnButtonClick(self, event):
        event.Skip()

    def timerOnTimer(self, event):
        self.playerM.stop()

    def vlc_play(self):
        mainURLM = "http://sttv-hls.cutv.com/lKGXIQa/500/82sl7G0.m3u8?sign=ed3eca5eab6ce70b6dc457ebe348830d&t=5b4d575c"
        mainURLB = "http://sttv-hls.cutv.com/7xjJK9d/500/y32j7j0.m3u8?sign=8116fb39139fc2c4ab4c90396b74c3b6&t=5b4d5770"
        self.MediaM = self.Instance.media_new(mainURLM)
        self.MediaB = self.Instance.media_new(mainURLB)
        self.playerM.set_media(self.MediaM)
        self.playerB.set_media(self.MediaB)
        handleM = self.m_panelLeft.GetHandle()
        handleB = self.m_panelRight.GetHandle()
        self.playerM.set_hwnd(handleM)
        self.playerB.set_hwnd(handleB)
        self.playerM.play()
        self.playerB.play()
        self.timer.Start(10000)

    

if __name__ == '__main__':
    app = wx.App(False)
    frame = FrameMain()
    frame.Show()
    app.MainLoop()
阅读 2.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题