Documentation
ExpressVideoSDK Video Call
Documentation
Demo APP
SDK Center
API Center
FAQ
Code Market
Console
Sign Up
Log In
中文站 English
  • Documentation
  • Video Call
  • Resources & Reference
  • SDK
  • Upgrade guide
  • Upgrade guide v3.0.0+

Upgrade guide v3.0.0+

Last updated:2023-10-25 14:51

  • If your current SDK version is lower than 3.0.0, when you need to upgrade to any version of 3.0.0 or above. Please make sure to read this document.
  • In addition, it is recommended that you refer to the business-related interfaces changes in the Release notes between the current version and the target version.

Express SDK version 3.0.0 optimizes the internal logic of the SDK, improves the stability of the SDK, the quality of audio and video calls, and the ease of use of the API interface. ZEGOCLOUD strongly recommends that you use the SDK version 3.0.0 or above.

This article provides general instructions and precautions when you upgrade the Express SDK version to 3.0.0 or above.

Delete description

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

method name Description
createStream Create publish data sources, including camera and microphone collection source data, screen sharing data, third-party source data, etc. You can use createZegoStream to implement the original function.
createLocalStreamView

Create a local media stream player component instance object. You can:

  1. Create an instance object zegoLocalStream through the createZegoStream interface.
  2. Call the playVideo and playAudio interfaces of the zegoLocalStream to play the audio and video to be published or that have been successfully published.
  3. Call the playCaptureVideo and playCaptureAudio interfaces to play the latest captured audio and video.
  • addTrack
  • replaceTrack
  • removeTrack

Add, replace, and remove audio and video tracks. 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 zegoLocalStream‘s collected or previewed audio and video.
  3. Call the updatePublishingStream interface to synchronize the audio and video of the zegoLocalStream.

Change your code

You can refer to the following sample code to change the interface.

Below version 3.0.0

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

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

// Start publishing
zg.startPublishingStream(publishID, stream);

// Create a third-party stream
const customStream = await zg.createStream({
        custom: {
            source: $('#customVideo')[0]
        }
    })
// Replace the preview video track of stream, and update the publishing streams
const videoTrack = customStream.getVideoTracks()[0]
await zg.replaceTrack(stream, videoTrack)

// Replace the preview audio track of stream, and update the publishing streams
const audioTrack1 = customStream.getAudioTracks()[0]
await zg.replaceTrack(stream, audioTrack1)

// Remobe the preview audio track of stream, and update the publishing streams
const audioTrack2 = stream.getAudioTracks()[0]
await zg.removeTrack(stream, audioTrack2)

// Add a preview video track of stream, and update the publishing streams
const stream2 = await zg.createStream({camera: {video: false, audio: true}});
const audioTrack3 = stream2.getAudioTracks()[0]
await zg.addTrack(stream2, audioTrack3)

Version 3.0.0 or above

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

// Play the newest collected video and audio
zegoLocalStream.playCaptureVideo(divElem);
zegoLocalStream.playCaptureAudio();

// Play videos and audios that are to be pushed or are already in the push stream. After the push is successful, the subsequent collection of zegoLocalStream will not be updated to the push stream synchronously. UpdatePublishingStream needs to be called for updates.
zegoLocalStream.playVideo(divElem);
zegoLocalStream.playAudio();

// Start publishing
zg.startPublishingStream(publishID, zegoLocalStream);

// Start capture a third-party video stream
const result1 = await zegoLocalStream.startCaptureCustomVideo({
    source: $('#customVideo')[0]
})
// Update the push stream to the latest collected third-party video stream, 0 is the updated video stream
await zg.updatePublishingStream(zegoLocalStream, 0)

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

// Update the push stream to the latest collected third-party audio stream, 1 is to update the audio stream
await zg.updatePublishingStream(zegoLocalStream, 1)

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

// Update the push stream to the latest collected microphone audio stream, 1 is to update the audio stream
await zg.updatePublishingStream(zegoLocalStream, 1)

// Stop collecting videos and update the publish stream synchronously
zegoLocalStream.stopCaptureVideo();

// Stop collecting audios and update the publish stream synchronously
zegoLocalStream.stopCaptureAudio();
Page Directory
  • Free trial
  • 提交工单
    咨询集成、功能及报价等问题
    电话咨询
    400 1006 604
    Get Consulting
    Scan Wechat QR code