Closed chfeizy closed 4 years ago
I think what you want to achieve can be done with transitions
. You can have a look at the docs here in my docs PR (which by the way hasn't gotten any attention since I created it in May...) stream-labs/obs-studio-node#658
osn.NodeObs.OBS_content_moveDisplay(displayId,-20000,-20000);
use this can hidden the old display
With transitions you can have nice animations, for example fades
This transitions is used when outputting, but I also use it when display
Instead of scene.name, // or use camera source Id here
in the setupPreview()
function use an empty string ( ""
). Then the output is used for the display source. Maybe you can also specify the transition name but I haven't tested this.
transition is great
Hi hrueger ,are the transition same like the obs client software
, accroding to the doc,i have created a scenelist(every scene contains a video source) when i toggle scene,transition type
seems not work @hrueger
EOBSTransitionTypes
Bad case
let i = 0;
setInterval(() => {
let index = i++ % sceneList.length;
const transition = osn.TransitionFactory.create(
"slide_transition",
"fade_transition",
{}
);
const scene = sceneList[index];
transition.set(scene);
const source = transition.getActiveSource();
console.log("source", source.name);
transition.start(500, scene);
osn.Global.setOutputSource(0, transition);
}, 3e3);
Oh, it works, just a misused. 🥲
Solutions: ✅
const transition = osn.TransitionFactory.create(
"swipe_transition",
"swipe_transition",
{}
);
const sceneList = [test_image, test_video].map((source) => {
const scene = osn.SceneFactory.create(source.name);
scene.add(source);
transition.set(scene);
// osn.Global.setOutputSource(1, scene);
return scene;
});
osn.Global.setOutputSource(0, transition);
let i = 0;
setInterval(() => {
let index = i++ % sceneList.length;
const scene = sceneList[index];
const source = transition.getActiveSource();
console.log("source", source.name);
transition.start(500, scene);
}, 3e3);
Need to switch camera and desktop scene preview
let displayId = 'display_1'; let sbounds; export function setupPreview(window, bounds) { displayId='display'+scene.name; s_bounds=bounds; console.log(displayId); osn.NodeObs.OBS_content_createSourcePreviewDisplay( window.getNativeWindowHandle(), scene.name, // or use camera source Id here displayId, ); osn.NodeObs.OBS_content_setShouldDrawUI(displayId, false); osn.NodeObs.OBS_content_setPaddingSize(displayId, 0); // Match padding color with main window background color osn.NodeObs.OBS_content_setPaddingColor(displayId, 255, 255, 255);
return resizePreview(bounds); }
and this can't change