def timestamps(self, event): tmillisec=vlc.libvlc_media_player_get_time(self.p) sec=tmillisec/1000 tsec= datetime.timedelta(seconds=sec) t=str(tsec) stamp=' ('+t+') ' self.text.insert(END, stamp)
def on_release(key): if key == Key.space: player.pause() # for alphanumeric keys use KeyCode as shown below if key == KeyCode.from_char("a"): t = vlc.libvlc_media_player_get_time(player) print("start - {0}".format(t)) notepad.write("'{0}',".format(t)) if key == KeyCode.from_char("d"): t = vlc.libvlc_media_player_get_time(player) print("end - {0}".format(t)) notepad.write("'{0}'\n".format(t)) if key == Key.esc: # Stop listener player.stop() notepad.close() return False
def get_playedTime_ms(self): return vlc.libvlc_media_player_get_time(vlc_player)
def get_playedTime(self): return dconverter.DurationConverter.get_time_str(self, vlc.libvlc_media_player_get_time(vlc_player))
def piProcess(state, lock, rate_q, change_q, first_path, second_path, third_path, timings, threshold=3.2, timer=300000, s_rate=0.69): """Provide work with media on Raspberry Pi :param state: current system state :param lock: lock for global variables :param rate_q: queue with video rate value :param change_q: queue with video change flag :param first_path: path to the first video :param second_path: path to the second video :param third_path: path to the image :param timings: list of timings with white screen in video in ms :param threshold: threshold value of video rate (the default is 3.2) :param timer: time value for looping value in ms (the default is 300000) :param s_rate: start video rate value (the default is 0.69) """ state_list = [1, 2, 3, 4, 5, 8] rate = s_rate last_timing = 0 # First video init by using VLC player Instance = vlc.Instance('--no-xlib') player = Instance.media_player_new() Media = Instance.media_new_path(first_path) player.set_media(Media) vlc.libvlc_media_player_set_rate(player, rate) player.set_fullscreen(True) # Images init image = cv2.imread(third_path) eye1 = cv2.imread('/home/pi/Desktop/Quest_final/eye.jpg') eye2 = cv2.imread('/home/pi/Desktop/Quest_final/eye1.jpg') winname = 'Quest' cv2.namedWindow(winname, cv2.WND_PROP_FULLSCREEN) cv2.setWindowProperty(winname, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN) while True: if state.value in state_list: if state.value == 1: # Black screen cv2.imshow(winname, image) cv2.waitKey(25) elif state.value == 2: # Start showing main video vlc.libvlc_media_player_set_rate(player, rate) player.play() elif state.value == 3: if not (rate_q.empty()): # Change video rate value rate = rate_q.get() vlc.libvlc_media_player_set_rate(player, rate) if rate >= threshold: # Quest end lock.acquire() state.value = 4 lock.release() continue if not (change_q.empty()): # Show sub video if change_q.get(): cv2.imshow(winname, eye1) cv2.waitKey(25) player.stop() changeVideo(second_path, winname, eye2) player.play() # Video loop cur_timing = vlc.libvlc_media_player_get_time(player) if cur_timing >= timer: vlc.libvlc_media_player_set_time(player, 1000) elif state.value == 4: # Play the video to the end vlc.libvlc_media_player_set_rate(player, 3.5) vlc.libvlc_media_player_set_time(player, timer) elif state.value == 5: # Go to the last frame pass elif state.value == 8: cv2.imshow(winname, image) cv2.waitKey(25) player.stop() rate = s_rate
def timecheck(self): tmillisec=vlc.libvlc_media_player_get_time(self.p) sec=tmillisec/1000 tsec= datetime.timedelta(seconds=sec) t=str(tsec) self.stamp=' ('+t+') '
def backwardAudio(self,event): current=vlc.libvlc_media_player_get_time(self.p) vlc.libvlc_media_player_set_time(self.p, current-30000)
def get_time(self): return vlc.libvlc_media_player_get_time(self.mp3_player)
keyword = basename(filepath) new_search = pylyrics.NeteaseSearch(keyword=keyword) songID = new_search.get_song_ID() print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') #print(new_search.get_song_url(encryptedID)) print('Searching lyrics for {}...'.format(keyword)) #with open('./fripSide - Run into the light.lrc','r') as lrcfile: lrctext = new_search.lrc() song = vlc.MediaPlayer(filepath) song.play() os.system('clear') #for i in range(14): # print('') lyrics = realtimelrc.RTLyrics(lrctext) sleep(2) for i in range(10000): sleep(0.1) ts = vlc.libvlc_media_player_get_time(song) #print(ts, end = ' ') output = lyrics.current_lyrics(ts + OFFSET) ts = str(ts) ts = ts.center(8) #output=output.center(60) sys.stdout.write(' Timestamp: ' + ts + 'ms ' + output + '\r') sys.stdout.flush() #print(lyrics.current_lyrics(ts + OFFSET), end = '')
5:13, 6:4, 7:18, 8:11, 9:17, 10:11, 11:17, 12:12, 13:1 } instance = vlc.Instance() media = instance.media_new("audio.mp3") player = instance.media_player_new() player.set_media(media) player.play() duration = libvlc_media_get_duration() duration/=100 pickle_in = open("data2send","rb") genre_dict = pickle.load(pickle_in) dict_size = len(genre_dict) time = 0 while True: # message = server.recv(2048) if(vlc.libvlc_media_player_get_time(player)>=genre_dict[time][0]): vlc.libvlc_audio_equalizer_release(player) vlc.libvlc_media_player_set_equalizer(player, vlc.libvlc_audio_equalizer_new_from_preset(genres.get(genre2.get(genre_dict[time][1])))) time++ if(time>=dict_size): break