Commit 7161e8bbe1
Unsigned
Layout: unified · split
start_video.py +12 −17
| @@ -1,14 +1,18 @@ | ||
| 1 | 1 | import os |
| 2 | 2 | import json |
| 3 | 3 | import socket |
| 4 | import random | |
| 4 | 5 | |
| 5 | os.system("mpv --input-ipc-server=/tmp/mpvsocket 'https://video.wixstatic.com/video/53f59c_bddcaac9d0b940c8b0238a429a47177e/1080p/mp4/file.mp4'") | |
| 6 | # Path to the MPV socket | |
| 7 | socket_path = '/tmp/mpvsocket' | |
| 6 | def start_video(link): | |
| 7 | salt = random.randint(0,500) | |
| 8 | os.system(f"mpv --input-ipc-server=/tmp/mpvsocket{salt} {link}") | |
| 9 | # Path to the MPV socket | |
| 10 | socket_path = f'/tmp/mpvsocket{salt}' | |
| 11 | ||
| 12 | # Connect to the MPV IPC socket | |
| 13 | client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | |
| 14 | client.connect(socket_path) | |
| 8 | 15 | |
| 9 | # Connect to the MPV IPC socket | |
| 10 | client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | |
| 11 | client.connect(socket_path) | |
| 12 | 16 | |
| 13 | 17 | def send_command(command): |
| 14 | 18 | """Send a command to MPV and return the response.""" |
| @@ -37,14 +41,5 @@ def stop(): | ||
| 37 | 41 | command = {"command": ["quit"]} |
| 38 | 42 | send_command(command) |
| 39 | 43 | |
| 40 | try: | |
| 41 | while True: | |
| 42 | time_pos = get_time_pos() | |
| 43 | print(f"Current Time: {time_pos:.2f} seconds") | |
| 44 | # Add any control commands here, for example, to pause or resume | |
| 45 | # pause() or play() or stop() | |
| 46 | time.sleep(1) | |
| 47 | except KeyboardInterrupt: | |
| 48 | stop() | |
| 49 | finally: | |
| 50 | client.close() | |
| 44 | # def get_data(): | |
| 45 | ||