How to use the agora-rtc-sdk.createStream function in agora-rtc-sdk

To help you get started, we’ve selected a few agora-rtc-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github netless-io / netless-rtc-react-whiteboard / src / components / whiteboard / ClassroomMedia.tsx View on Github external
private startRtc = (userId: number, channelId: string): void => {
        this.agoraClient = AgoraRTC.createClient({mode: "rtc", codec: "h264"});
        this.agoraClient.init(this.props.agoraAppId, () => {
            console.log("AgoraRTC client initialized");
        }, (err: any) => {
            console.log("AgoraRTC client init failed", err);
        });
        const localStream = AgoraRTC.createStream({
            streamID: userId,
            audio: true,
            video: true,
        });
        localStream.init(()  => {
            console.log("getUserMedia successfully");
            const netlessLocalStream = {
                ...localStream,
                state: {isVideoOpen: true, isAudioOpen: true},
            };
            this.setState({localStream: netlessLocalStream});
            netlessLocalStream.play("rtc_local_stream");
            this.agoraClient.join(this.props.agoraAppId, channelId, userId, (uid: string) => {
                this.props.setMediaState(true);
                console.log("User " + uid + " join channel successfully");
                this.agoraClient.publish(localStream, (err: any) => {
github netless-io / netless-rtc-react-whiteboard / src / rtc / RtcDesktop.tsx View on Github external
private startRtc = (uid: number, channelId: string): void => {
        this.setSliderExtending();
        this.setState({isStartBtnLoading: true});
        if (!this.agoraClient) {
            this.agoraClient = AgoraRTC.createClient({mode: "live", codec: "h264"});
            this.agoraClient.init(this.props.agoraAppId, () => {
                console.log("AgoraRTC client initialized");
            }, (err: any) => {
                console.log("AgoraRTC client init failed", err);
            });
        }
        const localStream = AgoraRTC.createStream({
            streamID: uid,
            audio: true,
            video: true,
            screen: false,
        });
        localStream.init(()  => {
            console.log("getUserMedia successfully");
            this.setState({localStream: localStream});
            localStream.play("rtc_local_stream");
            this.rtcClock = setInterval( () => this.setState({joinRoomTime: this.state.joinRoomTime + 1}), 1000);
            this.setState({isStartBtnLoading: false});
            this.agoraClient.join(this.props.agoraAppId, channelId, uid, (uid: number) => {
                console.log("User " + uid + " join channel successfully");
                if (!this.props.isRtcReadOnly) {
                    this.agoraClient.publish(localStream, (err: any) => {
                        console.log("Publish local stream error: " + err);
github netless-io / netless-rtc-react-whiteboard / src / rtc / RtcDesktop.tsx View on Github external
private startRtc = (uid: number, channelId: string): void => {
        this.setSliderExtending();
        this.setState({isStartBtnLoading: true});
        if (!this.agoraClient) {
            this.agoraClient = AgoraRTC.createClient({mode: "live", codec: "h264"});
            this.agoraClient.init(this.props.agoraAppId, () => {
                console.log("AgoraRTC client initialized");
            }, (err: any) => {
                console.log("AgoraRTC client init failed", err);
            });
        }
        const localStream = AgoraRTC.createStream({
            streamID: uid,
            audio: true,
            video: true,
            screen: false,
        });
        localStream.init(()  => {
            console.log("getUserMedia successfully");
            this.setState({localStream: localStream});
            localStream.play("rtc_local_stream");
            this.rtcClock = setInterval( () => this.setState({joinRoomTime: this.state.joinRoomTime + 1}), 1000);
            this.setState({isStartBtnLoading: false});
            this.agoraClient.join(this.props.agoraAppId, channelId, uid, (uid: number) => {
                console.log("User " + uid + " join channel successfully");
                if (!this.props.isRtcReadOnly) {
                    this.agoraClient.publish(localStream, (err: any) => {
                        console.log("Publish local stream error: " + err);

agora-rtc-sdk

AgoraRTC SDK for web

SEE LICENSE IN LICENSE.md
Latest version published 2 years ago

Package Health Score

45 / 100
Full package analysis