$duration) { sendError('Invalid time values', 400); } // Initialize streaming system $streaming = new VStreaming(); // Update watch progress $streaming->updateWatchProgress($videoKey, $userId, $currentTime, $duration); sendSuccess([ 'message' => 'Progress updated successfully', 'video_key' => $videoKey, 'current_time' => $currentTime, 'duration' => $duration, 'watch_percentage' => ($duration > 0) ? ($currentTime / $duration) * 100 : 0 ]); } catch (Exception $e) { VLogger::getInstance()->error('Video progress API error', [ 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); sendError('Internal server error', 500); } /** * Send success response */ function sendSuccess($data, $code = 200) { http_response_code($code); echo json_encode([ 'success' => true, 'data' => $data, 'timestamp' => time() ]); exit(); } /** * Send error response */ function sendError($message, $code = 400) { http_response_code($code); echo json_encode([ 'success' => false, 'error' => $message, 'timestamp' => time() ]); exit(); } ?>