Add subtitles and start offset to playvideo command
This commit is contained in:
@@ -126,12 +126,16 @@ curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -
|
||||
|
||||
___
|
||||
|
||||
- Tell the client to play a video, defined by the filename parameter:
|
||||
- Tell the client to play a video, defined by the `filename` parameter. It has optional parameters `subtitles`, which should point to a subtitle file and defaults to `null`, and `secondsfromstart` which indicated the timestap at what the video should start, which defaults to `0`:
|
||||
|
||||
`
|
||||
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "playvideo", "filename": "stallman.webm"}'
|
||||
`
|
||||
|
||||
`
|
||||
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "playvideo", "filename": "stallman.webm", "subtitles": "stallman.vtt", "secondsfromstart": 69}'
|
||||
`
|
||||
|
||||
___
|
||||
|
||||
- Seek the currently played video to a timestamp (in seconds):
|
||||
|
14
main.py
14
main.py
@@ -150,8 +150,14 @@ async def control_endpoint(request: Request):
|
||||
|
||||
elif data['command'] == "playvideo" and 'filename' in data:
|
||||
filename = data['filename']
|
||||
await playvideo(filename)
|
||||
logger.info(f"Video playback requested: {filename}")
|
||||
subtitles = None
|
||||
seconds_from_start = 0
|
||||
if 'subtitles' in data:
|
||||
subtitles = data['subtitles']
|
||||
if 'secondsfromstart' in data:
|
||||
seconds_from_start = data['secondsfromstart']
|
||||
await playvideo(filename, subtitles, seconds_from_start)
|
||||
logger.info(f"Video playback requested: {filename} with subtitles {subtitles} starting {seconds_from_start} seconds from start.")
|
||||
|
||||
elif data['command'] == "seekvideo" and 'timestamp' in data:
|
||||
timestamp = data['timestamp']
|
||||
@@ -301,8 +307,8 @@ async def setscreen_single(ws: WebSocket, screen: str):
|
||||
async def setscreen(screen: str):
|
||||
return await manager.broadcast_binary({"type": "setscreen", "screen": screen})
|
||||
|
||||
async def playvideo(filename: str):
|
||||
return await manager.broadcast_binary({"type": "playvideo", "filename": filename})
|
||||
async def playvideo(filename: str, subtitles: str, seconds_from_start: int):
|
||||
return await manager.broadcast_binary({"type": "playvideo", "filename": filename, "subtitles": subtitles, "seconds_from_start": seconds_from_start})
|
||||
|
||||
async def seekvideo(timestamp: int):
|
||||
return await manager.broadcast_binary({"type": "seekvideo", "timestamp": timestamp})
|
||||
|
Reference in New Issue
Block a user