Add studio mode support for scene switching
- Detect when OBS is in studio mode using GetStudioModeEnabled API - Switch preview scene instead of program scene when studio mode is active - Maintain backward compatibility for normal mode operation - Provide clear feedback indicating studio mode operation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
fdf781dcf9
commit
e777b3d422
1 changed files with 23 additions and 9 deletions
|
@ -32,16 +32,30 @@ export async function POST(request: NextRequest) {
|
|||
try {
|
||||
const obsClient = await getOBSClient();
|
||||
|
||||
// Switch to the requested scene
|
||||
await obsClient.call('SetCurrentProgramScene', { sceneName });
|
||||
// Check if studio mode is active
|
||||
const { studioModeEnabled } = await obsClient.call('GetStudioModeEnabled');
|
||||
|
||||
console.log(`Successfully switched to scene: ${sceneName}`);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: { sceneName },
|
||||
message: `Switched to ${sceneName} layout`
|
||||
});
|
||||
if (studioModeEnabled) {
|
||||
// In studio mode, switch the preview scene
|
||||
await obsClient.call('SetCurrentPreviewScene', { sceneName });
|
||||
console.log(`Successfully switched preview to scene: ${sceneName} (Studio Mode)`);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: { sceneName, studioMode: true },
|
||||
message: `Preview set to ${sceneName} layout (Studio Mode) - ready to transition`
|
||||
});
|
||||
} else {
|
||||
// Normal mode, switch program scene directly
|
||||
await obsClient.call('SetCurrentProgramScene', { sceneName });
|
||||
console.log(`Successfully switched to scene: ${sceneName}`);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: { sceneName, studioMode: false },
|
||||
message: `Switched to ${sceneName} layout`
|
||||
});
|
||||
}
|
||||
} catch (obsError) {
|
||||
console.error('OBS WebSocket error:', obsError);
|
||||
return NextResponse.json(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue