logo
On this page

Upgrade Guide for Version 3.0.0 and Above

2023-09-25

Warning
  • If your current SDK is lower than version 3.0.0 and you need to upgrade to any SDK version 3.0.0 or above, please be sure to read this article.
  • In addition, it is recommended that you refer to the change notes between the two version intervals in the Release Notes based on your current version number and target version number, and check interfaces related to your business.

Express SDK version 3.0.0 optimizes the SDK's internal logic, improves SDK stability, Video Call quality, and the usability of API interfaces. ZEGO strongly recommends that you use SDK version 3.0.0 or above.

This article will introduce the instructions and precautions when upgrading Express SDK to version 3.0.0 and above.

Deprecation Notes

The following interfaces will be officially deprecated in version 3.0.0. Please update your code logic in time to avoid affecting your normal business use.

Deprecated interfaceDeprecation description
createStreamCreate Stream Publishing data sources, including camera and microphone Capture sources, screen sharing data, third-party source data, etc. This function is deprecated in version 3.0.0. Please use createZegoStream to implement the original functionality.
createLocalStreamView

Create a local media stream player component instance object. This function is deprecated in version 3.0.0. You can:

  1. Create an instance object zegoLocalStream through the createZegoStream interface.
  2. Call the playVideo and playAudio interfaces of the zegoLocalStream instance to play audio/video to be published or already successfully published.
  3. Call playCaptureVideo and playCaptureAudio interfaces to play the latest Captured audio/video.

Add, replace, and remove audio/video tracks. These functions are deprecated in version 3.0.0. You can:

  1. Create an instance object zegoLocalStream through the createZegoStream interface.
  2. Call the startCaptureCamera, startCaptureCustomVideo, startCaptureMicrophone and other interfaces of the zegoLocalStream instance to update the audio/video Captured and previewed by zegoLocalStream.
  3. Call the updatePublishingStream interface to synchronize the audio/video of zegoLocalStream in Stream Publishing.

Change Example Code

You can refer to the following example code to update your code logic.

Before version 3.0.0

// Create camera and microphone stream by default
const stream = zg.createStream()

// Create media stream player component
const viewer = zg.createLocalStreamView(stream);
// Play media stream
viewer.play(divElem);

// Stream Publishing
zg.startPublishingStream(publishID, stream);

// Create third-party audio/video stream
const customStream = await zg.createStream({
        custom: {
            source: $('#customVideo')[0]
        }
    })
// Replace stream's preview video track and synchronously update Stream Publishing
const videoTrack = customStream.getVideoTracks()[0]
await zg.replaceTrack(stream, videoTrack)

// Replace stream's preview audio track and synchronously update Stream Publishing
const audioTrack1 = customStream.getAudioTracks()[0]
await zg.replaceTrack(stream, audioTrack1)

// Remove stream's preview audio track and synchronously update Stream Publishing
const audioTrack2 = stream.getAudioTracks()[0]
await zg.removeTrack(stream, audioTrack2)

// Add stream's preview audio track and synchronously update Stream Publishing
const stream2 = await zg.createStream({camera: {video: false, audio: true}});
const audioTrack3 = stream2.getAudioTracks()[0]
await zg.addTrack(stream2, audioTrack3)

Version 3.0.0 and above

// Create camera and microphone stream by default
const zegoLocalStream = await zg.createZegoStream()

// Play the latest Captured video and audio
zegoLocalStream.playCaptureVideo(divElem);
zegoLocalStream.playCaptureAudio();

// Play video and audio to be published or already in Stream Publishing. After successful Stream Publishing, zegoLocalStream's subsequent Capture will not synchronously update to Stream Publishing. Updates require calling updatePublishingStream
zegoLocalStream.playVideo(divElem);
zegoLocalStream.playAudio();

// Stream Publishing
zg.startPublishingStream(publishID, zegoLocalStream);

// Capture third-party audio/video stream
const result1 = await zegoLocalStream.startCaptureCustomVideo({
    source: $('#customVideo')[0]
})
// Update Stream Publishing to the latest Captured third-party video stream, 0 means updating video stream
await zg.updatePublishingStream(zegoLocalStream, 0)

// Capture third-party audio stream
const result2 = await zegoLocalStream.startCaptureCustomAudio({
    source: $('#externerAudio')[0]
})

// Update Stream Publishing to the latest Captured third-party audio stream, 1 means updating audio stream
await zg.updatePublishingStream(zegoLocalStream, 1)


// Capture microphone audio stream
const result3 = await zegoLocalStream.startCaptureMicrophone()

// Update Stream Publishing to the latest Captured microphone audio stream, 1 means updating audio stream
await zg.updatePublishingStream(zegoLocalStream, 1)

// Stop Capturing video, synchronously update Stream Publishing
zegoLocalStream.stopCaptureVideo();

//Stop Capturing audio, synchronously update Stream Publishing
zegoLocalStream.stopCaptureAudio();

Previous

Release Notes

Next

Common Error Codes

On this page

Back to top