Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import vlc
- import time
- import schedule
- import threading
- import os
- def playMovie():
- instance = vlc.Instance()
- player = instance.media_player_new()
- media = instance.media_new(sciezka)
- player.set_media(media)
- player.set_fullscreen(True)
- # Rozpoczęcie odtwarzania
- player.play()
- # Oczekiwanie na zakończenie odtwarzania
- while not player.get_state() == vlc.State.Ended:
- time.sleep(1)
- # Zatrzymaj odtwarzacz po zakończeniu filmu
- player.stop()
- # os.system("cls")
- print("Film zakończony.")
- def schedule_play():
- print(f"Odtwarzanie filmu o godzinie: {time_to_start}")
- schedule.every().day.at(time_to_start).do(playMovie)
- print('''Wybierz opcję:
- 1. 9.30
- 2. 11.00
- 3. Inne\n''')
- x = int(input())
- if x == 1:
- time_to_start = "09:15"
- sciezka = input("Podaj ścieżkę filmu: ")
- while not os.path.exists(sciezka):
- print("Podana ścieżka nie istnieje. Spróbuj ponownie.")
- sciezka = input("Podaj ścieżkę filmu: ")
- os.system("cls")
- elif x == 2:
- time_to_start = "10:45"
- sciezka = input("Podaj ścieżkę filmu: ")
- while not os.path.exists(sciezka):
- print("Podana ścieżka nie istnieje. Spróbuj ponownie.")
- sciezka = input("Podaj ścieżkę filmu: ")
- os.system("cls")
- else:
- time_to_start = input("Podaj godzinę rozpoczęcia: ")
- sciezka = input("Podaj ścieżkę filmu: ")
- while not os.path.exists(sciezka):
- print("Podana ścieżka nie istnieje. Spróbuj ponownie.")
- sciezka = input("Podaj ścieżkę filmu: ")
- os.system("cls")
- # Zarejestruj zadanie w harmonogramie
- schedule_play()
- def run_schedule():
- while True:
- schedule.run_pending()
- time.sleep(1)
- # Uruchom harmonogram w osobnym wątku
- schedule_thread = threading.Thread(target=run_schedule)
- schedule_thread.start()
- # Czekaj na zakończenie wątku harmonogramu
- schedule_thread.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement