Commit 7161e8bbe1

7161e8bbe11de037e435a85f79cd1aa0e16ad961

parent: 0bbc5efc2f

Unsigned

Wraient <wraient.911@gmail.com> · 2024-08-25 11:49 UTC

start video function

Layout: unified · split

start_video.py +12 −17
@@ -1,14 +1,18 @@
1import os 1import os
2import json 2import json
3import socket 3import socket
4import random
4 5
5os.system("mpv --input-ipc-server=/tmp/mpvsocket 'https://video.wixstatic.com/video/53f59c_bddcaac9d0b940c8b0238a429a47177e/1080p/mp4/file.mp4'") 6def start_video(link):
6# Path to the MPV socket 7 salt = random.randint(0,500)
7socket_path = '/tmp/mpvsocket' 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
10client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
11client.connect(socket_path)
12 16
13def send_command(command): 17def send_command(command):
14 """Send a command to MPV and return the response.""" 18 """Send a command to MPV and return the response."""
@@ -37,14 +41,5 @@ def stop():
37 command = {"command": ["quit"]} 41 command = {"command": ["quit"]}
38 send_command(command) 42 send_command(command)
39 43
40try: 44# def get_data():
41 while True: 45
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)
47except KeyboardInterrupt:
48 stop()
49finally:
50 client.close()