def print_version(): """Print version of vlc.py and of libvlc""" try: print('%s: %s (%s)' % (basename(vlc.__file__), vlc.__version__, vlc.build_date)) print('LibVLC version: %s (%#x)' % (vlc.bytes_to_str( vlc.libvlc_get_version()), vlc.libvlc_hex_version())) print('LibVLC compiler: %s' % vlc.bytes_to_str(vlc.libvlc_get_compiler())) if vlc.plugin_path: print('Plugin path: %s' % vlc.plugin_path) except Exception: print('Error: %s' % sys.exc_info()[1])
def PrintInfo(self): """Print information about the media""" with self.playerLock: try: #vlc.print_version() media = self.player.get_media() media.parse( ) #this is required or else duration of media will be 0 print('Duration: {}'.format( datetime.timedelta(milliseconds=media.get_duration()))) print('State: %s' % self.player.get_state()) print('Media: %s' % vlc.bytes_to_str(media.get_mrl())) print('Track: %s/%s' % (self.player.video_get_track(), self.player.video_get_track_count())) print('Current time: %s/%s' % (self.player.get_time(), media.get_duration())) print('Position: %s' % self.player.get_position()) #position is [0.0 .. 1.0] #print('FPS: %s (%d ms)' % (self.player.get_fps(), self._mspf())) print('Rate: %s' % self.player.get_rate()) print('Video size: %s' % str(self.player.video_get_size(0))) # num=0 print('Scale: %s' % self.player.video_get_scale()) print('Aspect ratio: %s' % self.player.video_get_aspect_ratio()) print('Subtitle count: {}'.format( self.player.video_get_spu_count())) #print('Window:' % player.get_hwnd() except Exception: import sys print('Error: %s' % sys.exc_info()[1])
def cur_state(self): media = self.vlc_player.get_media() audio_status = self.vlc_player.get_state() state = { 'audio_status': str(audio_status), 'volume': self.volume, 'is_playing': self.is_playing() } if media: state['media'] = vlc.bytes_to_str(media.get_mrl()) state['current_time'] = self.vlc_player.get_time() if self.current_track != None: state['current_track'] = self.current_track['title'] state['duration'] = self.current_track['duration'] state['thumbnail'] = self.current_track['thumbnail'] else: state['current_track'] = None state['duration'] = -1 state['thumbnail'] = '' else: state['media'] = None json_str = json.dumps(state) return json_str
def get_status(): media = player.get_media() status = {'state': str(player.get_state())} if media: status['media'] = vlc.bytes_to_str(media.get_mrl()) status['current_time'] = player.get_time() status['duration'] = media.get_duration() return status
def get_status(): media = player.get_media() status = {'state': str(player.get_state()), 'volume': volume} if equalizer_supported: status['equalizer_enabled'] = equalizer_enabled status['equalizer_preset'] = equalizer_preset status['equalizer_preamp_level'] = equalizer_preamp_level status['equalizer_band_levels'] = equalizer_band_levels if media: status['media'] = vlc.bytes_to_str(media.get_mrl()) status['current_time'] = player.get_time() status['duration'] = media.get_duration() return status
def get_status(): media = player.get_media() status = {"state": str(player.get_state()), "volume": volume} if equalizer_supported: status["equalizer_enabled"] = equalizer_enabled status["equalizer_preset"] = equalizer_preset status["equalizer_preamp_level"] = equalizer_preamp_level status["equalizer_band_levels"] = equalizer_band_levels if media: status["media"] = vlc.bytes_to_str(media.get_mrl()) status["current_time"] = player.get_time() status["duration"] = media.get_duration() return status
def print_python(): """Print Python and O/S version""" from platform import architecture, mac_ver, uname, win32_ver if 'intelpython' in sys.executable: t = 'Intel-' # elif 'PyPy ' in sys.version: # t = 'PyPy-' else: t = '' t = '%sPython: %s (%s)' % (t, sys.version.split()[0], architecture()[0]) if win32_ver()[0]: t = t, 'Windows', win32_ver()[0] elif mac_ver()[0]: t = t, ('iOS' if sys.platform == 'ios' else 'macOS'), mac_ver()[0] else: try: import distro # <http://GitHub.com/nir0s/distro> t = t, vlc.bytes_to_str(distro.name()), vlc.bytes_to_str( distro.version()) except ImportError: t = (t, ) + uname()[0:3:2] print(' '.join(t))
def is_youtube_video(m=None): if m is None: m = player.get_media() return m is not None and \ 'http://www.youtube.com' in vlc.bytes_to_str(m.get_mrl())
f.close() except Exception: print(sys.exc_info()) exit(1) # Allow stream to start playing time.sleep(2) current_track = '' current_url = '' # Monitor track meta data and update currently_playing file if the track changed while True: try: if str(player.get_state()) == 'State.Playing': cur = str(media.get_meta(vlc.Meta.Artist)) + ' - ' + str( media.get_meta(vlc.Meta.Title)) if current_track != cur or current_url != vlc.bytes_to_str( media.get_mrl()): # Update currently_playing file if the track has changed current_track = cur current_url = vlc.bytes_to_str(media.get_mrl()) print('Current track: %s - %s' % (media.get_meta( vlc.Meta.Artist), media.get_meta(vlc.Meta.Title))) song_info_json = json.dumps({ "artist": media.get_meta(vlc.Meta.Artist), "song": media.get_meta(vlc.Meta.Title), "state": str(player.get_state()) })
if nowplaying: # 'nowplaying' metadata is "almost" always: title - artist if '-' in nowplaying: parts = nowplaying.split(' - ', 1) latest_info['artist'] = parts[0] latest_info['track'] = parts[1] else: latest_info['artist'] = None latest_info['track'] = nowplaying else: latest_info['artist'] = media.get_meta(vlc.Meta.Artist) latest_info['track'] = media.get_meta(vlc.Meta.Title) # Update currently_playing file if the track has changed if cur_info != latest_info or cur_url != vlc.bytes_to_str( media.get_mrl()): cur_info = latest_info cur_url = vlc.bytes_to_str(media.get_mrl()) log(f"Current track: {latest_info['track']} - {latest_info['artist']}" ) if args.test: log('success') sys.exit(0) if args.song_info: try: f = open(args.song_info, "wt") f.write(json.dumps(cur_info)) f.close() except Exception: