Sam.L
Sam.L

Reputation: 173

Recorder.js IOS Safari

In all browser all works fine, but in IOS I can record only once, next I can't do it until I reload the page. I can't figure where is a problem cause I don't receive any errors.

componentDidMount = async () => {
    let stream;
    try {
        stream = await navigator.mediaDevices.getUserMedia({ audio: true });
    } catch (error) {
        this.setState({
            accept: false
        })
    }
    this.setState({ stream });
}

startRecord = () => {
    const { stream } = this.state;
    const audioContext = new (window.AudioContext || window.webkitAudioContext)();
    const recorder = new RecorderJS(audioContext);
    recorder.init(stream);
    this.setState(
        {
            recorder,
            recording: true
        },
        () => {
            recorder.start();
        }
    );
}

stopRecord = async () => {
    const { recorder } = this.state;
    recorder.stop().then(({ blob }) => {
        this.uploadFile(blob);
    })
    this.setState({
        recording: false
    });
}

Upvotes: 1

Views: 624

Answers (0)

Related Questions