Пример #1
0
    def __init__(self):
        self.current_freq: Union[float, None] = None
        self.stations: List[RadioStation] = []
        self.start_time_ms = time.time() * 1000
        self.current_station_name = ''
        self.equalizer = vlc.AudioEqualizer()

        # Init noise players
        self.noise_player: vlc.MediaListPlayer = vlc.MediaListPlayer()
        self.noise_player.set_playback_mode(vlc.PlaybackMode.loop)
        self._load_media(self.noise_player, vlc.Media(RadioStation.find_file_path('noise.mp3')))

        # Init music player
        self.music_player: vlc.MediaListPlayer = vlc.MediaListPlayer()
        self.music_player.set_playback_mode(vlc.PlaybackMode.loop)
Пример #2
0
 def OnOpen(self):
     if os.path.isfile("sch.txt"):
         pass
         print("found sch.txt")
         print("playing from this file instead")
     else:
         print("sch.txt not found")
         fullname = askdirectory(initialdir="/", title="Select Directory")
         if os.path.isdir(fullname):
             video_frmt = [
                 '.mp4', '.m4a', '.m4v', '.f4v', '.f4a', '.m4b', '.m4r',
                 '.f4b', '.mov', '.wmv', '.wma', '.asf', '.webm', '.flv',
                 '.avi', '.wav', '.mkv'
             ]
             mastr = []
             hold = []
             mastrw = []
             for dir in os.listdir(fullname):
                 dirpath = os.path.join(fullname, dir).replace("\\", "/")
                 for path, directories, files in os.walk(dirpath):
                     for filename in files:
                         name, ext = os.path.splitext(filename)
                         if ext in video_frmt:
                             hold.append(
                                 os.path.join(path,
                                              filename).replace("\\", "/"))
                         else:
                             pass
                 if len(hold):
                     mastr.append(hold)
                 else:
                     pass
                 hold = []
             while mastr:
                 randitem = choice(mastr)
                 if len(randitem):
                     mastrw.append(randitem.pop(0))
                 else:
                     mastr.remove(randitem)
             with open('sch.txt', 'w') as f:
                 for fullpath in mastrw:
                     f.write(fullpath + '\n')
             print("created sch.txt")
     with open("sch.txt") as flplpay:
         sch_list = flplpay.read().split('\n')
         for path_line in sch_list:
             self.media = vlc.Media(path_line)
             self.media_list.add_media(self.media)
     self.media_list_player = vlc.MediaListPlayer()
     self.media_list_player.set_media_list(self.media_list)
     print("Created MediaListPlayer")
     if platform.system() == 'Windows':
         self.media_list_player.get_media_player().set_hwnd(
             self.GetHandle())
     else:
         self.media_list_player.get_media_player().set_xwindow(
             self.GetHandle())
     self.OnPlay()
     self.volslider.set(
         self.media_list_player.get_media_player().audio_get_volume())
Пример #3
0
    def create_video(self):
        """Create video widget."""

        self.instance = vlc.Instance()

        video_widget = QFrame()
        self.mediaplayer = self.instance.media_player_new()
        if system() == 'Linux':
            self.mediaplayer.set_xwindow(video_widget.winId())
        elif system() == 'Windows':
            self.mediaplayer.set_hwnd(video_widget.winId())
        elif system() == 'darwin':  # to test
            self.mediaplayer.set_nsobject(video_widget.winId())
        else:
            lg.warning('unsupported system for video widget')
            return

        self.medialistplayer = vlc.MediaListPlayer()
        self.medialistplayer.set_media_player(self.mediaplayer)
        event_manager = self.medialistplayer.event_manager()
        event_manager.event_attach(vlc.EventType.MediaListPlayerNextItemSet,
                                   self.next_video)

        self.idx_button = QPushButton()
        self.idx_button.setText('Start')
        self.idx_button.clicked.connect(self.start_stop_video)

        layout = QVBoxLayout()
        layout.addWidget(video_widget)
        layout.addWidget(self.idx_button)
        self.setLayout(layout)
Пример #4
0
def song_player(param_db, param_sessionID, repeat, test):
    """
    Instantiate the media list player and its playlist.
    Playlist is created with one random song in it.
    :param param_db: The database object.
    :param param_sessionID: Current user's session ID.
    :param repeat: Flag for repeating a song which was previously played. If set to False, it will skip previously played songs.
    :param test: Flag for allowing console output. If set to False, it will not output messages to the console.
    """

    global media_list_player, playlist, db, sessionID, repeatFlag, testFlag

    db = param_db
    sessionID = param_sessionID
    repeatFlag = repeat
    testFlag = test

    playlist = vlc.MediaList()

    # Add a random song to the playlist.
    #   allSongs = [song['name'] for song in list(Tracklist.get_all_songs(db))]
    #  random_song = random.choice(allSongs)
    # path = os.path.relpath('./audio/tracks/' + random_song + '.mp3')
    # playlist.add_media(path)

    # Link playlist to media list player.
    media_list_player = vlc.MediaListPlayer()
    media_list_player.set_playback_mode(vlc.PlaybackMode.loop)
    media_list_player.set_media_list(playlist)

    # Add events for changing tracks.
    add_events()
Пример #5
0
 def run(self):
     self.root = Tk()
     self.root.title("Output")
     self.root.attributes('-fullscreen', True)
     self.root.geometry('1280x720')
     self.root.configure(background='black')
     self.root.protocol("WM_DELETE_WINDOW", self.callback)
     self.frame = Frame(self.root, width=1280, height=720)
     self.croma = Frame(self.root,
                        width=1280,
                        height=720,
                        background='black')
     self.label = Label(self.croma,
                        text=" ",
                        font=('Helvatical bold', 400),
                        fg='#ffffff',
                        background='black')
     self.label.pack()
     self.vlabel = Label(self.croma,
                         fg='#ffffff',
                         text="vermelho=",
                         font=('Helvatical bold', 30),
                         background='black')
     self.alabel = Label(self.croma,
                         fg='#ffffff',
                         text="azul=",
                         font=('Helvatical bold', 30),
                         background='black')
     self.vlabel.pack()
     self.alabel.pack()
     self.croma.pack()
     self.media_player = vlc.MediaListPlayer()
     self.iniciar_vlc()
     self.root.mainloop()
Пример #6
0
 def startPlayer(self):
     # Create Player
     self.mediaListPlayer = vlc.MediaListPlayer()
     self.mediaListPlayer.set_playback_mode(vlc.PlaybackMode.loop)
     # Load Json
     self.json_file = ('.\Chart.json')
     self.json_obj = json.load(open(self.json_file))
     # Create MEdia List
     self.createMediaList()
Пример #7
0
    def __init__(self, target):
        self.target = target
        self.instance = vlc.Instance()

        self.medialist = vlc.MediaList()
        self.player = vlc.MediaListPlayer(self.instance)
        self.player.set_media_player(self.instance.media_player_new())
        self.player.set_media_list(self.medialist)

        self.mrl_map = {}
Пример #8
0
 def __init__(self):
     self.player = vlc.MediaListPlayer()
     # Give the player a default volume of 50, because otherwise it defaults to 0
     # until the first song is played
     self.player.get_media_player().audio_set_volume(50)
     self.player.event_manager().event_attach(
         vlc.EventType.MediaListPlayerNextItemSet, self.next_playlist_item
     )
     self.playlist_index = -1
     self.playlist = []
     self.callbacks = []
def main():
    #print( "main" )
    global inputLen, prevInputLen, mediaList, mediaListPlayer, mediaPlayer, position

    # Wait the system to boot up correctly
    #time.sleep(10)

    # Open video player
    try:
        print(" load the video ")
        # create a list of media
        mediaList = vlc.MediaList()
        # and add itmes to it
        mediaList.add_media(pathToVideoFile1)
        mediaList.add_media(pathToVideoFile2)
        # create the player which will play that list
        mediaListPlayer = vlc.MediaListPlayer()
        mediaListPlayer.set_media_list(mediaList)
    except Exception as exc:
        print("something went wrong {}".format(exc))
        quit()

    mediaListPlayer.set_playback_mode(vlc.PlaybackMode.loop)
    mediaListPlayer.play_item(mediaList.item_at_index(0))
    mediaPlayer = mediaListPlayer.get_media_player()
    mediaPlayer.toggle_fullscreen()

    inputLen = getInputDevices()
    prevInputLen = inputLen

    # Main loop
    while True:
        # check is someone plugged in a mouse or a keyboard
        if (areThereNewInputsDevices()):
            # new input devices have been found
            # script must be stopped in order
            # to let space for the user to work
            # with the Pi

            # quit video player
            videoPlayer.stop(
            )  # will exit current vlc window (desktop will be visible)

            # kill all alive thread
            # find a way to do this

            # exit the python script
            quit()
        else:
            #print("position {}".format(position) )
            #if position >= 0.99:
            #	videoPlayer.set_position( 0.0 )
            time.sleep(0.1)
Пример #10
0
def play_album(thefreezer, args):
    outfname, _ = thefreezer.zip_album(args.album_to_zip)
    # -o forces overwrite lol
    subprocess.run(["unzip", "-qq", "-o", outfname, "-d", FREEZER_TMP_DIR])
    filelist = sorted(glob.glob(outfname[:-4] + "/*.mp3"))
    print(os.path.basename(outfname)[:-4])
    for f in filelist:
        print(os.path.basename(f))
    media_list = vlc.MediaList(filelist)
    player = vlc.MediaListPlayer()
    player.set_media_list(media_list)
    player.play()
    # Dump user into a PDB session. Songs can be controlled from there in
    # lieu of a real interface of some kind.
    l = loop_handler(player)
    l.go()
Пример #11
0
 def run(self):
     self.funcionando = True
     self.root = Tk()
     self.root.title("Output")
     self.root.geometry('1280x720')
     self.root.configure(background='#00ff00')
     self.root.protocol("WM_DELETE_WINDOW", self.callback)
     self.frame = Frame(self.root, width=1280, height=720)
     self.croma = Frame(self.root,
                        width=1280,
                        height=720,
                        background='#00ff00')
     Canvas(self.croma, bg='#00ff00', width=1280, height=720).pack()
     self.croma.pack()
     self.media_player = vlc.MediaListPlayer()
     self.iniciar_vlc()
     self.root.mainloop()
Пример #12
0
    def play_list_musics(self, rutas_musicas, escucha_orden):

        self.media_player = vlc.MediaListPlayer()
        self.player = vlc.Instance()
        self.media_list = self.player.media_list_new()

        for musica in rutas_musicas:
            self.media = self.player.media_new(musica)
            self.media_list.add_media(self.media)

        self.media_player.set_media_list(self.media_list)

        self.media_player.play()

        #Cambiamos el valor a True para que no se vuelva a ejecutar la funcion de play
        self.reproduciendo = True

        time.sleep(1)
        #creamos este bucle para que el programa no se cierre y que por lo tanto no finalice la
        #reproduccion hasta que se lo ordenemos al llamar a la funcion que modifica el valor de
        #la variable finalizar la cual esta siendo evaluada constantemente en el bucle While
        while True:
            #La funcion escucha_orden se la recibimos por parámetro
            self.orden = escucha_orden()
            print(self.orden)
            if 'siguiente' in self.orden:
                self.media_player.next()
            elif 'anterior' in self.orden:
                self.media_player.previous()
            elif 'pausa' in self.orden:
                self.media_player.pause()
            elif 'reinicia' in self.orden:
                self.media_player.play()
            elif 'finaliza' in self.orden:
                self.media_player.stop()
                self.reproduciendo = False
                break
            elif self.cambiar_tipo_musica:
                self.cambiar_tipo_musica = False
                break

        return None
Пример #13
0
 def __init__(self, statusCallback=None):
     self.logger = logging.getLogger(__name__)
     self.path = None
     self.pathdict = {}
     self.player = None
     self.trackstatus = statusCallback  # We want to notify only from Manager
     try:
         self._list = vlc.MediaList()
         self._player = vlc.MediaPlayer()
         self.player = vlc.MediaListPlayer()
         self.player.set_media_player(self._player)
         self.player.set_media_list(self._list)
         self.player.event_manager().event_attach(
             vlc.EventType.MediaListPlayerNextItemSet,
             self.playInfo
         )
     except NameError:
         self.logger.error("Can't initialize vlc player instance. Missing \
                           libvlc in system?",
                           "Try to install VLC player")
Пример #14
0
    def _prepare(self, url):
        def _cb(event):
            print "Event: ", event.type, event.u

        self._media_list_player = vlc.MediaListPlayer()
        self.player = vlc.MediaPlayer()
        self._media_list_player.set_media_player(self.player)

        media_list_player_event_manager = self._media_list_player.event_manager(
        )
        media_list_player_event_manager.event_attach(
            vlc.EventType.MediaListPlayerNextItemSet, _cb)

        media_list_player_event_manager = self.player.event_manager()
        media_list_player_event_manager.event_attach(
            vlc.EventType.MediaPlayerEndReached, _cb)
        media_list_player_event_manager.event_attach(
            vlc.EventType.MediaPlayerMediaChanged, _cb)

        media_list = vlc.MediaList()

        media_list.add_media(url)
        self._media_list_player.set_media_list(media_list)
        self.player.audio_set_volume(self.current_vol)
Пример #15
0
display = DigitalOutputDevice(23)

#funny sentences to say hello and good bye
hellos = [
    'Coucou !', 'Salut a toi !', 'Toujours en vie ?', 'Comment vas-tu ?',
    'Besoin de rien\nEnvie de toi...', 'BlBblblBLbblb !!', 'Pourquoi pas ?',
    'Salamalekoum', ':-)'
]
byes = [
    'Tchao l\'ami', 'Hasta la vista,\nBaby !', 'Hasta la victoria !',
    'A plus \ndans l\'bus !', 'Bisous !'
]

context = {
    'playerList':
    vlc.MediaListPlayer(),
    'stations': [
        ('Sing Sing', 'http://stream.sing-sing-bis.org:8000/singsingaac256'),
        ('Radio Sympa', 'http://radio2.pro-fhi.net:9095/stream2'),
        ('mega', 'http://live.francra.org:8000/Radio-Mega'),
        ('France Inter',
         'http://direct.franceinter.fr/live/franceinter-midfi.mp3'),
        ('FIP', 'http://direct.fipradio.fr/live/fipnantes-midfi.mp3'),
        ('France culture',
         'http://direct.franceculture.fr/live/franceculture-midfi.mp3'),
        ('St Fereol', 'http://live.francra.org:8000/RadioSaintFerreol.m3u'),
        ('Grenouille', 'http://live.radiogrenouille.com/live.m3u'),
    ],
    'current_station':
    0,
    'current_lcd_text':
Пример #16
0
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        #Tela secundaria
        self.telaSecundaria = QtWidgets.QWidget()
        self.telaSecundaria.setStyleSheet("background-color: rgb(0, 0, 0);")
        self.frameVideo.setStyleSheet("background-color: rgb(0, 0, 0);")

        # dialogo para o link do youtube
        self.inputYoutube = QtWidgets.QInputDialog()
        self.inputYoutube.textValueSelected.connect(self.linkMidia)


        #Tela principal
        self.listaDeMidia = []
        self.botaoAdicionar.clicked.connect(self.adicionarExterno) # conector botaoAdicionar para função adicionarExterno
        self.botaoRemover.clicked.connect(self.removerItemDePlayList) # conector botaoRemover para função removerItemDePlayList
        self.listaPlaylist.itemClicked.connect(self.itemclicadoPlayList)  # conector listaPlaylist para função removerItemDePlayList
        self.listaPlaylist.itemDoubleClicked.connect(self.midiaParaReproduzirVindoDaLista)
        self.botaoVolume.clicked.connect(self.mutar)
        self.botaoPlay.clicked.connect(self.play)
        self.botaoStop.clicked.connect(self.stop)
        #self.slideVolume.sliderMoved.connect(self.volume)
        self.slideMusica.sliderPressed.connect(self.slidePressed)
        self.slideMusica.sliderReleased.connect(self.slideReleased)
        self.slideMusica.sliderMoved.connect(self.mudartempo)
        self.comboMusica.activated.connect(self.mudarFaixaDeAudio)
        self.comboLegenda.activated.connect(self.mudarFaixaDeLegenda)
        self.areaBusca.returnPressed.connect(self.busca)
        self.listaBanco.itemDoubleClicked.connect(self.midiaParaReproduzirVindoDoBanco)
        self.botaoAdicionar_2.clicked.connect(self.itemDoBancoParaPlaylist)
        self.listaBanco.itemClicked.connect(self.itemClicadoBanco)
        self.botaoRedimencionar.clicked.connect(self.redimencionar)
        self.botaoPlayList.clicked.connect(self.playList)
        self.listaTrecho.setVisible(False)
        self.botaoIniciarPlayback.clicked.connect(self.botao_iniciar_playback_clicado)
        self.botaoYoutube.clicked.connect(self.adicionarFromYoutube)
        
        self.slideMusicaPressionado = 0
        self.botaoRedimencionarEstado = 0
        self.ativarPlayList = False
        self.botaoIniciarPB_clicado = False
        self.audios = False
        self.legendas = False

        #atalhos no techado
        atalhoPlay = QShortcut(QtGui.QKeySequence("space"), self)
        atalhoPlay.activated.connect(self.play)

        atalhoStop = QShortcut(QtGui.QKeySequence("s"), self)
        atalhoStop.activated.connect(self.stop)

        atalhoSairColetanea = QShortcut(QtGui.QKeySequence("esc"), self)
        atalhoSairColetanea.activated.connect(self.voltar_coletanea)


        #reprodutor
        self.player = vlc.Instance()
        self.mediaList = self.player.media_list_new()
        self.mediaInstancia = self.player.media_list_new()
        
        self.reprodutorInstance2 = self.player.media_player_new()
    
        self.reprodutorInstance = self.player.media_player_new()
        
        if sys.platform.startswith('linux'): # para linux X Server
            self.reprodutorInstance2.set_xwindow(self.telaSecundaria.winId())
            self.reprodutorInstance.set_xwindow(self.frameVideo.winId())


        elif sys.platform == "win32": # para Windows
            self.reprodutorInstance2.set_hwnd(self.telaSecundaria.winId())
            self.reprodutorInstance.set_hwnd(self.frameVideo.winId())

        elif sys.platform == "darwin": # para MacOS
            self.reprodutorInstance.set_nsobject(int(self.frameVideo.winId()))
            self.reprodutorInstance2.set_nsobject(int(self.telaSecundaria.winId()))

        self.reprodutorInstance.stop()
        self.reprodutorInstance.audio_set_volume(100)
        
        self.reprodutorInstancePlayList = vlc.MediaListPlayer()
        self.reprodutorInstancePlayList.set_media_list(self.mediaList)
        self.reprodutorInstancePlayList.set_media_player(self.reprodutorInstance)

        self.reprodutorInstancePlayListExterno = vlc.MediaListPlayer()
        self.reprodutorInstancePlayListExterno.set_media_list(self.mediaList)
        self.reprodutorInstancePlayListExterno.set_media_player(self.reprodutorInstance2)
        
        #lista a tela secundaria do sistema

        display_monitor = len(QtGui.QGuiApplication.screens()) #quantas telas tem no sistema
        monitor = QDesktopWidget().screenGeometry(1) #propriedades do monitor
        self.telaSecundaria.move(monitor.left(), monitor.top()) #informando para a tela secundaria qual monitor aparecerá
        
        #Eventos
        event_manager = self.reprodutorInstance2.event_manager()
        event_manager.event_attach(vlc.EventType.MediaPlayerPlaying, self.reproduzindo)
        event_manager.event_attach(vlc.EventType.MediaPlayerMuted, self.mute)
        event_manager.event_attach(vlc.EventType.MediaPlayerPositionChanged,self.tempo)
        event_manager.event_attach(vlc.EventType.MediaPlayerEndReached,self.fimdaReproducao)
        
        
        #Timer
        self.timer = QTimer(self)
Пример #17
0
def make_player():
    player = vlc.MediaPlayer()
    mlplayer = vlc.MediaListPlayer()
    mlplayer.set_media_player(player)
    return mlplayer
Пример #18
0
#setting which mp3 folder to use
if len(sys.argv) <=1:
    print('Please specify a folder') #for testing, won't be kept for non-lcd V1
    sys.exit(1)
folder = sys.argv[1]
files = glob.glob(folder+"/*.mp3")
if len(files) == 0:
    print('No mp3 files in directory', folder,'..exiting') #for testing, won't be kept for non-lcd V1
    sys.exit(1)

#vlc player setup
player = vlc.MediaPlayer()
#playlist setup
medialist = vlc.MediaList(files)
#linking it all
mlplayer = vlc.MediaListPlayer()
mlplayer.set_media_player(player)
mlplayer.set_media_list(medialist)

#defining the shutdown button
def shutdown():
    check_call(['sudo', 'poweroff'])
while True:
    if playpausebutton.is_pressed:
        if mlplayer.is_playing():
            mlplayer.pause() #pauses the music when the playpausebutton is pressed
        else:
            mlplayer.play() #plays the music when the playpausebutton is pressed
    elif stopbutton.is_pressed:
        mlplayer.stop() #stops the music when the stopbutton is pressed
    elif trackforwardsbutton.is_pressed:
Пример #19
0
    #set playlist playback mode to loop
    media_list_player.set_playback_mode(1)

    #play video loop
    media_list_player.play_item(media1)


#main
if __name__ == '__main__':

    #set up Button
    button17 = Button(17)
    button17.when_pressed = when_pressed

    #create mediaListPlayer object
    media_list_player = vlc.MediaListPlayer()

    #create vlc instance
    player = vlc.Instance()

    #create media list for loop video
    media_list = player.set_media_list_new()
    #create media list for one shot video
    media_list2 = player.set_media_list_new()

    #create media elements
    #loop video
    media1 = player.media_new("video.mp4")
    media_list.add_media(media1)
    #add media to media_list
    media_list_player.set_media_list(media_list)