Please ensure that the development environment meets the following technical requirements:
zego-express-engine-electron-plugin-screen-capture
as a plug-in of zego-express-engine-electron
, both are published on the npm repository at the same time, and need to be combined to complete the screen sharing function. Please integrate the dependent zego-express-engine-electron
first. For related documents, please refer to the SDK Integration Guidelines of zego-express-engine-electron
.
In the corresponding project directory, execute the following command in the command line to install the latest version of the SDK.
npm install zego-express-engine-electron-plugin-screen-capture
When you execute npm install
to install the SDK, if the download of the npm official website image is slow, you can switch to the domestic image.
Use the following code to introduce the SDK into the project.
const zgScreenCapture = window.require('zego-express-engine-electron-plugin-screen-capture').ZegoExpressPluginScreenCaptureInstance;
After the SDK is introduced, developers can call other interfaces provided by the SDK between initialization and de-initialization to achieve more collection functions, such as Sharing Selected Screen, Sharing Selected Window and Window Thumbnails. It is recommended that the developer set the log configuration and monitor the error callback after initialization, so that the problem can be discovered in time when the collection error occurs.
const zgScreenCaptureLogLevel = window.require('zego-express-engine-electron-plugin-screen-capture').ZegoExpressPluginScreenCaptureLogLevel;
// Initialize
zgScreenCapture.init();
// Set the log configuration (the log file is generated in the project root directory by default and named with zegoscreencaplog as the prefix)
zgScreenCapture.setLogConfig(logLevel=zgScreenCaptureLogLevel.LogLevelDebug, logPath='.');
// Monitor the error callback during the collection process
zgScreenCapture.on("onScreenCaptureError", param => {
console.log("onScreenCaptureError: errorCode=", param.errorCode);
});
// after initialization/deinitialization
// Call other SDK interfaces to achieve more functions
// xxx
// Deinitialization
zgScreenCapture.uninit();