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 @@
11import os
22import json
33import socket
4import random
45
5os.system("mpv --input-ipc-server=/tmp/mpvsocket 'https://video.wixstatic.com/video/53f59c_bddcaac9d0b940c8b0238a429a47177e/1080p/mp4/file.mp4'")
6# Path to the MPV socket
7socket_path = '/tmp/mpvsocket'
6def 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)
815
9# Connect to the MPV IPC socket
10client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
11client.connect(socket_path)
1216
1317def send_command(command):
1418 """Send a command to MPV and return the response."""
@@ -37,14 +41,5 @@ def stop():
3741 command = {"command": ["quit"]}
3842 send_command(command)
3943
40try:
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)
47except KeyboardInterrupt:
48 stop()
49finally:
50 client.close()
44# def get_data():
45