def speedUpAudio(self, event):
     self.rate=self.rate*1.25
     vlc.libvlc_media_player_set_rate(self.p, self.rate)
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 slowDownAudio(self, event):
     self.rate=self.rate*0.75
     vlc.libvlc_media_player_set_rate(self.p, self.rate)