20 lines
659 B
Python
20 lines
659 B
Python
from simple_term_menu import TerminalMenu
|
|
import vlc
|
|
from database import Database
|
|
|
|
def play(url: str, database: Database):
|
|
start_pos = 0
|
|
viewing_data = database.get_viewing_data(url)
|
|
if (viewing_data != None):
|
|
menu = TerminalMenu([f"go back to {str(viewing_data.get('last_pos'))}", "restart from 0:00"])
|
|
response = menu.show()
|
|
if (response == None):
|
|
return (1);
|
|
elif (response == 0):
|
|
start_pos = viewing_data.get("last_pos")
|
|
vlc_instance = vlc.Instance()
|
|
player = vlc_instance.media_player_new()
|
|
media = vlc_instance.media_new(url)
|
|
player.set_media(media)
|
|
player.play()
|