Skip to content

Commit

Permalink
fix(examples): publish local track on create
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious committed Mar 17, 2023
1 parent 6e5dbfe commit a1ad261
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/overview/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export const App = () => {
const [audioTrack, setAudioTrack] = useState<IMicrophoneAudioTrack | null>(null);
useEffect(() => {
if (micOn && !audioTrack) {
sp(AgoraRTC.createMicrophoneAudioTrack({ ANS: true, AEC: true })).then(setAudioTrack);
sp(AgoraRTC.createMicrophoneAudioTrack({ ANS: true, AEC: true })).then(track => {
client.publish(track);
setAudioTrack(track);
});
}
if (audioTrack) {
audioTrack.setEnabled(micOn);
Expand All @@ -63,7 +66,10 @@ export const App = () => {
const [videoTrack, setVideoTrack] = useState<ICameraVideoTrack | null>(null);
useEffect(() => {
if (cameraOn && !videoTrack) {
sp(AgoraRTC.createCameraVideoTrack()).then(setVideoTrack);
sp(AgoraRTC.createCameraVideoTrack()).then(track => {
client.publish(track);
setVideoTrack(track);
});
}
if (videoTrack) {
videoTrack.setEnabled(cameraOn);
Expand Down

0 comments on commit a1ad261

Please sign in to comment.