Advertisement
misiekii123

MovieProjection Offline

Mar 15th, 2024 (edited)
687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.97 KB | Software | 0 0
  1. import vlc
  2. import time
  3. import schedule
  4. import threading
  5. import os
  6.  
  7. def playMovie():
  8.     instance = vlc.Instance()
  9.     player = instance.media_player_new()
  10.     media = instance.media_new(sciezka)
  11.     player.set_media(media)
  12.     player.set_fullscreen(True)
  13.  
  14.     # Rozpoczęcie odtwarzania
  15.     player.play()
  16.  
  17.     # Oczekiwanie na zakończenie odtwarzania
  18.     while not player.get_state() == vlc.State.Ended:
  19.         time.sleep(1)
  20.  
  21.     # Zatrzymaj odtwarzacz po zakończeniu filmu
  22.     player.stop()
  23.  
  24.     # os.system("cls")
  25.     print("Film zakończony.")
  26.  
  27. def schedule_play():
  28.     print(f"Odtwarzanie filmu o godzinie: {time_to_start}")
  29.     schedule.every().day.at(time_to_start).do(playMovie)
  30.  
  31. print('''Wybierz opcję:
  32.      1. 9.30
  33.      2. 11.00
  34.      3. Inne\n''')
  35. x = int(input())
  36.  
  37. if x == 1:
  38.     time_to_start = "09:15"
  39.     sciezka = input("Podaj ścieżkę filmu: ")
  40.     while not os.path.exists(sciezka):
  41.         print("Podana ścieżka nie istnieje. Spróbuj ponownie.")
  42.         sciezka = input("Podaj ścieżkę filmu: ")
  43.     os.system("cls")
  44. elif x == 2:
  45.     time_to_start = "10:45"
  46.     sciezka = input("Podaj ścieżkę filmu: ")
  47.     while not os.path.exists(sciezka):
  48.         print("Podana ścieżka nie istnieje. Spróbuj ponownie.")
  49.         sciezka = input("Podaj ścieżkę filmu: ")
  50.     os.system("cls")
  51. else:
  52.     time_to_start = input("Podaj godzinę rozpoczęcia: ")
  53.     sciezka = input("Podaj ścieżkę filmu: ")
  54.     while not os.path.exists(sciezka):
  55.         print("Podana ścieżka nie istnieje. Spróbuj ponownie.")
  56.         sciezka = input("Podaj ścieżkę filmu: ")
  57.     os.system("cls")
  58.  
  59.  
  60.  
  61. # Zarejestruj zadanie w harmonogramie
  62. schedule_play()
  63.  
  64. def run_schedule():
  65.     while True:
  66.         schedule.run_pending()
  67.         time.sleep(1)
  68.  
  69. # Uruchom harmonogram w osobnym wątku
  70. schedule_thread = threading.Thread(target=run_schedule)
  71. schedule_thread.start()
  72.  
  73. # Czekaj na zakończenie wątku harmonogramu
  74. schedule_thread.join()
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement